{
  "$schema": "https://ambiqai.github.io/helia-ui/schema/reference-model-1.json",
  "generatedFrom": {
    "sourceCommit": "f341fb11f7f5d77a4974ba8273c4cd55d67c21f0",
    "tool": "pyref",
    "version": "1.7.3"
  },
  "language": "python",
  "modules": [
    {
      "description": "Grain pipelines over a ``DataSource``.",
      "name": "grain_data",
      "path": "helia_edge.data.grain_data",
      "submodules": [],
      "summary": "Grain pipelines over a DataSource.",
      "symbols": [
        {
          "description": "Read ``source`` through Grain: shuffle, repeat, transform, batch and prefetch.\n\nThe order is source, shuffle (a new permutation each epoch), repeat, ``transform``, batch, so\nbatches run across epoch boundaries. Record order and transform randomness depend only on\n``seed``, not on ``workers``. Every ``iter()`` replays the same elements, so a Keras ``fit``\nthat iterates once per epoch sees the same epoch each time: for Keras training, pass\n``num_epochs=None`` and set ``steps_per_epoch``.",
          "examples": [],
          "id": "helia_edge.data.grain_data.to_grain",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "to_grain",
          "params": [
            {
              "description": "Records addressed by index.",
              "name": "source",
              "type": "DataSource[Any]"
            },
            {
              "default": "None",
              "description": "Seed for the shuffle and for the per-record generator passed to ``transform``,\nfrom 0 to 2**32 - 1. Required when ``shuffle`` is set or ``transform`` is given.",
              "name": "seed",
              "type": "int | None"
            },
            {
              "default": "False",
              "description": "Shuffle the records of every epoch (each of the ``num_epochs`` passes).",
              "name": "shuffle",
              "type": "bool"
            },
            {
              "default": "None",
              "description": "``transform(record, rng) -> record``, run per record in the Grain workers;\n``rng`` is a NumPy generator derived from ``seed`` and the record's position.",
              "name": "transform",
              "type": "Callable[[Any, np.random.Generator], Any] | None"
            },
            {
              "default": "None",
              "description": "Stack this many records into one batch of NumPy arrays; None keeps single\nrecords.",
              "name": "batch_size",
              "type": "int | None"
            },
            {
              "default": "False",
              "description": "Drop the last batch if it is smaller than ``batch_size``.",
              "name": "drop_remainder",
              "type": "bool"
            },
            {
              "default": "1",
              "description": "Number of passes over ``source``; None repeats indefinitely.",
              "name": "num_epochs",
              "type": "int | None"
            },
            {
              "default": "0",
              "description": "Grain worker processes; 0 reads in this process.",
              "name": "workers",
              "type": "int"
            },
            {
              "default": "1",
              "description": "Elements each worker prepares ahead.",
              "name": "worker_buffer_size",
              "type": "int"
            }
          ],
          "raises": [
            {
              "description": "If ``seed`` is missing when needed or out of range, or a count is not a\npositive integer (``workers`` may be 0).",
              "type": "ValueError"
            },
            {
              "description": "If Grain is not installed (``helia-edge[grain]``).",
              "type": "ImportError"
            }
          ],
          "returns": [
            {
              "description": "grain.IterDataset: Re-iterable; each ``iter()`` starts from the first element.",
              "type": "grain.IterDataset"
            }
          ],
          "signature": "to_grain(\n    source: DataSource[Any],\n    *,\n    seed: int | None = None,\n    shuffle: bool = False,\n    transform: Callable[[Any, np.random.Generator], Any] | None = None,\n    batch_size: int | None = None,\n    drop_remainder: bool = False,\n    num_epochs: int | None = 1,\n    workers: int = 0,\n    worker_buffer_size: int = 1,\n) -> grain.IterDataset",
          "source": {
            "line": 24,
            "path": "helia_edge/data/grain_data.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/data/grain_data.py#L24"
          },
          "summary": "Read source through Grain: shuffle, repeat, transform, batch and prefetch."
        }
      ]
    }
  ],
  "name": "helia_edge"
}
