class_docstr: Imagenet 2012, aka ILSVRC 2012.
class_docstr_tok: ["Imagenet","2012",",","aka","ILSVRC","2012","."]
docstr: Yields examples.
docstr_tok: ["Yields","examples","."]
code: def _generate_examples(
      self, archive, validation_labels=None, labels_exist=True
  ):
      """Yields examples."""
      if not labels_exist:  # Test split
          for key, example in imagenet_common.generate_examples_test(
              archive
          ):
              yield key, example
      if validation_labels:  # Validation split
          for (
              key,
              example,
          ) in imagenet_common.generate_examples_validation(
              archive, validation_labels
          ):
              yield key, example
      # 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:
          label = fname[:-4]  # fname is something like 'n01632458.tar'
          # TODO(b/117643231): in py3, the following lines trigger tarfile module
          # to call `fobj.seekable()`, which Gfile doesn't have. We should find an
          # alternative, as this loads ~150MB in RAM.
          fobj_mem = io.BytesIO(fobj.read())
          for image_fname, image in tfds.download.iter_archive(
              fobj_mem, tfds.download.ExtractMethod.TAR_STREAM
          ):
              image = self._fix_image(image_fname, image)
              record = {
                  "file_name": image_fname,
                  "image": image,
                  "label": label,
              }
              yield image_fname, record
  
file_path: datasets/tensorflow_datasets/datasets/imagenet2012/imagenet2012_dataset_builder.py
imports: import io
  import os
  from absl import logging
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  from tensorflow_datasets.datasets.imagenet2012 import imagenet_common
  import tensorflow_datasets.public_api
label_desc: Use image node_id 4 for calling the Builder obj's underlying member method code with example usage: obj._generate_examples(archive, validation_labels, labels_exist) without return types