# PreprocessResponse

An object that holds the samples data and length. This object is generated in the Preprocessing Function for each dataset slice. Then passed to the **input encoders**, **ground\_truth encoders** and **metadata** functions as an argument.

```python
from code_loader.contract.enums import DataStateType

@dataclass
class PreprocessResponse:
    length: Optional[int] = None
    data: Any = None
    sample_ids: Optional[Union[List[str], List[int]]] = None
    state: Optional[DataStateType] = None
    sample_id_type: Optional[Union[Type[str], Type[int]]] = None
```

For more on `PreprocessResponse`:

<table><thead><tr><th width="167.39065467110788">Args</th><th></th></tr></thead><tbody><tr><td><code>length</code></td><td><em>(int, deprecated)</em> Number of samples in the slice. Deprecated — use <code>sample_ids</code> instead.</td></tr><tr><td><code>data</code></td><td><em>(Any)</em> Dictionary / pandas.DataFrame / List or any object that describes the dataset features. The <code>data</code> parameter is later passed to the <strong>input encoders, ground_truth encoders</strong>, and <strong>metadata</strong> functions.</td></tr><tr><td><code>sample_ids</code></td><td>A list of unique identifiers for each sample in the slice. IDs should be either a list of ints or strings. Preferred over <code>length</code>.</td></tr><tr><td><code>state</code></td><td><em>(</em><a href="../enums/datastatetype">DataStateType</a><em><strong>, optional</strong>)</em> The dataset split this response belongs to. Recommended to always set explicitly.</td></tr><tr><td><code>sample_id_type</code></td><td>(str/int, optional) The type of the sample IDs. Inferred automatically when using <code>sample_ids</code>.</td></tr></tbody></table>

## Examples

#### Basic Usage

```python
from code_loader.contract.datasetclasses import PreprocessResponse
preprocess_response = PreprocessResponse(sample_ids=list(x_df.index), data=x_df)
```

#### Within the Preprocess Function

Full examples can be found at the **Dataset Integration** section of the following guides:

* [**MNIST Guide**](https://docs.tensorleap.ai/guides/full-guides/mnist-guide)
* [**IMDB Guide**](https://docs.tensorleap.ai/guides/full-guides/imdb-guide)
