class_docstr: Grain DataSource class.
  
  Warning: this is an experimental class. The interface might change in the
  future without backwards compatibility.
  
  It acts as a wrapper around `array_record.ArrayRecordDataSource` that can read
  from ArrayRecords. It exposes `__len__` and `__getitem__` to serve as a data
  source.
class_docstr_tok: ["Grain","DataSource","class",".","Warning",":","this","is","an","experimental","class",".","The","interface","might","change","in","the","future","without","backwards","compatibility",".","It","acts","as","a","wrapper","around","`","array_record.ArrayRecordDataSource","`","that","can","read","from","ArrayRecords",".","It","exposes","`","__len__","`","and","`","__getitem__","`","to","serve","as","a","data","source","."]
docstr: Retrieves items by batch.
  
  This method allows PyTorch to load records by batch, rather than one by one.
  
  Args:
    record_keys: a sequence of keys.
  
  Returns:
    The records associated with the keys.
  
  Raises:
    IndexError: If the number of retrieved records is incorrect.
docstr_tok: ["Retrieves","items","by","batch",".","This","method","allows","PyTorch","to","load","records","by","batch",",","rather","than","one","by","one",".","Args",":","record_keys",":","a","sequence","of","keys",".","Returns",":","The","records","associated","with","the","keys",".","Raises",":","IndexError",":","If","the","number","of","retrieved","records","is","incorrect","."]
code: def __getitems__(self, record_keys: Sequence[int]) -> Sequence[Any]:
      """Retrieves items by batch.
  
      This method allows PyTorch to load records by batch, rather than one by one.
  
      Args:
        record_keys: a sequence of keys.
  
      Returns:
        The records associated with the keys.
  
      Raises:
        IndexError: If the number of retrieved records is incorrect.
      """
      records = self.data_source.__getitems__(record_keys)
      features = self.dataset_info.features
      if len(record_keys) != len(records):
          raise IndexError(
              f"Requested {len(record_keys)} records but got"
              f" {len(records)} records."
              f"{record_keys=}, {records=}"
          )
      return [
          features.deserialize_example_np(
              record, decoders=self.decoders
          )
          for record in records
      ]
  
file_path: datasets/tensorflow_datasets/core/data_sources/array_record.py
imports: from collections.abc import Sequence
  import dataclasses
  from typing import Any, Optional, Sequence, TypeVar
  from absl import logging
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import decode
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import array_record_data_source
  import tree
label_desc: Use image node_id 5 for calling the ArrayRecordDataSource obj's underlying member method code with example usage: obj.__getitems__(record_keys) and returns: unknown