class_docstr: DatasetBuilder for imagenet_pi dataset.
class_docstr_tok: ["DatasetBuilder","for","imagenet_pi","dataset","."]
code: def _generate_examples(
      self,
      archive,
      annotator_labels,
      annotator_confidences,
      validation_labels=None,
  ):
      # Validation split.
      if validation_labels:
          for fname, fobj in archive:
              assert fname in validation_labels
              assert fname in annotator_labels
              assert fname in annotator_confidences
              record = {
                  "file_name": fname,
                  "image": fobj,
                  "clean_label": validation_labels[fname],
                  "annotator_labels": annotator_labels[fname],
                  "annotator_confidences": annotator_confidences[fname],
              }
              yield fname, record
  
      # Training split. Main archive contains archives names after a synset noun.
      # Each sub-archive contains pictures associated to that synset.
      for fname, fobj in archive:
          assert fname.endswith(".tar")
          label = fname[:-4]  # fname is something like 'n01632458.tar'
          fobj_mem = io.BytesIO(fobj.read())
          for image_fname, image in tfds.download.iter_archive(
              fobj_mem, tfds.download.ExtractMethod.TAR_STREAM
          ):
              record = {
                  "file_name": image_fname,
                  "image": image,
                  "clean_label": label,
                  "annotator_labels": annotator_labels[image_fname],
                  "annotator_confidences": annotator_confidences[
                      image_fname
                  ],
              }
              yield image_fname, record
  
file_path: datasets/tensorflow_datasets/datasets/imagenet_pi/imagenet_pi_dataset_builder.py
imports: import io
  import os
  from etils import epath
  import numpy
  from tensorflow_datasets.datasets.imagenet2012 import imagenet_common
  import tensorflow_datasets.public_api
label_desc: Use image node_id 9 for calling the Builder obj's underlying member method code with example usage: obj._generate_examples(archive, annotator_labels, annotator_confidences, validation_labels) without return types