# helia_edge.data.torch_data

Torch ``DataLoader`` over batches produced by another loader.

## helia_edge.data.torch_data.to_torch_loader

`function` · `python`

```python
to_torch_loader(dataset: Iterable[Any]) -> torch.utils.data.DataLoader
```

Wrap a re-iterable of NumPy batches, such as a Grain dataset, as a Torch ``DataLoader``.

The loader adds no batching, shuffling or workers of its own: each ``iter()`` iterates
``dataset`` once more in this process and converts its NumPy leaves to tensors, keeping the
structure (dicts, lists, tuples) and the order. Arrays in worker shared memory are copied
first, so tensors stay valid after the next element arrives. Do batching and parallel reads
in ``dataset``.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| dataset | Iterable[Any] | Required | Re-iterable whose ``iter()`` starts from the first element. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | torch.utils.data.DataLoader | torch.utils.data.DataLoader: With ``batch_size=None``, so elements pass through as they are. |

**Raises**

| Name | Description |
| --- | --- |
| ImportError | If Torch is not installed (``helia-edge[torch]``). |

Source: `helia_edge/data/torch_data.py:29`
