class_docstr: DatasetBuilder for CIFAR-10H dataset.
class_docstr_tok: ["DatasetBuilder","for","CIFAR-10H","dataset","."]
docstr: Generate CIFAR-10H examples as dicts.
  
  Uses self._cifar_info as configuration.
  
  Args:
    split_prefix (str): Prefix that identifies the split (e.g. "train" or
      "test").
    filepaths (list[str]): The files to use to generate the data.
    human_annotations_path (str): Path to human labels and metadata.
  
  Yields:
    The cifar examples, as defined in the dataset info features.
docstr_tok: ["Generate","CIFAR-10H","examples","as","dicts",".","Uses","self._cifar_info","as","configuration",".","Args",":","split_prefix","(","str",")",":","Prefix","that","identifies","the","split","(","e.g",".","``","train","''","or","``","test","''",")",".","filepaths","(","list","[","str","]",")",":","The","files","to","use","to","generate","the","data",".","human_annotations_path","(","str",")",":","Path","to","human","labels","and","metadata",".","Yields",":","The","cifar","examples",",","as","defined","in","the","dataset","info","features","."]
code: def _generate_examples(
      self, split_prefix, filepaths, human_annotations_path
  ):
      """Generate CIFAR-10H examples as dicts.
  
      Uses self._cifar_info as configuration.
  
      Args:
        split_prefix (str): Prefix that identifies the split (e.g. "train" or
          "test").
        filepaths (list[str]): The files to use to generate the data.
        human_annotations_path (str): Path to human labels and metadata.
  
      Yields:
        The cifar examples, as defined in the dataset info features.
      """
      label_keys = self._cifar_info.label_keys
      index = 0  # Using index as key since data is always loaded in same order.
  
      human_annotations = None
      if "test" in split_prefix:
          human_annotations = _load_human_annotations(
              human_annotations_path
          )
  
      for path in filepaths:
          for labels, np_image in _load_data(path, len(label_keys)):
              record = dict(zip(label_keys, labels))
              # Note: "id" is only provided for the user convenience. To shuffle the
              # dataset we use `index`, so that the sharding is compatible with
              # earlier versions.
              record["id"] = "{}{:05d}".format(split_prefix, index)
              record["image"] = np_image
  
              if "test" in split_prefix:
                  record["human_labels"] = _get_field_for_example(
                      human_annotations, index, "chosen_label"
                  )
                  record["reaction_times"] = _get_field_for_example(
                      human_annotations, index, "reaction_time"
                  )
                  record["trial_indices"] = _get_field_for_example(
                      human_annotations, index, "trial_index"
                  )
                  record["annotator_ids"] = _get_field_for_example(
                      human_annotations, index, "annotator_id"
                  )
                  record["soft_label"] = tf.reduce_mean(
                      tf.one_hot(
                          record["human_labels"], 10, dtype=np.float32
                      ),
                      axis=0,
                  ).numpy()
  
              else:
                  # There is no annotator data for the train split
                  record["human_labels"] = []
                  record["reaction_times"] = []
                  record["trial_indices"] = []
                  record["annotator_ids"] = []
                  record["soft_label"] = tf.one_hot(
                      record["label"], 10, dtype=np.float32
                  ).numpy()
  
              yield index, record
              index += 1
  
file_path: datasets/tensorflow_datasets/image_classification/cifar10_h/cifar10_h.py
imports: import collections
  import os
  from etils import epath
  import numpy
  from tensorflow_datasets.core.utils.lazy_imports_utils import pandas
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  import tensorflow_datasets.public_api
label_desc: Use image node_id 4 for calling the Cifar10H obj's underlying member method code with example usage: obj._generate_examples(split_prefix, filepaths, human_annotations_path) without return types