class_docstr: Class balanced subset of Imagenet 2012 dataset.
code: def _split_generators(self, dl_manager):
      # Import ImageNet here to avoid circular dependencies
  
      train_path = os.path.join(
          dl_manager.manual_dir, "ILSVRC2012_img_train.tar"
      )
      val_path = os.path.join(
          dl_manager.manual_dir, "ILSVRC2012_img_val.tar"
      )
  
      # We don't import the original test split, as it doesn't include labels.
      # These were never publicly released.
      if not tf.io.gfile.exists(train_path) or not tf.io.gfile.exists(
          val_path
      ):
          raise AssertionError(
              "ImageNet requires manual download of the data. Please download "
              "the train and val set and place them into: {}, {}".format(
                  train_path, val_path
              )
          )
  
      # Download and load subset file.
      subset_file = dl_manager.download(
          SUBSET2FILES[self.builder_config.name]
      )
      if isinstance(
          subset_file, list
      ):  # it will only be a list during testing,
          subset_file = subset_file[
              0
          ]  # where the first entry is 1percent.txt.
      with epath.Path(subset_file).open() as fp:
          subset = set(
              fp.read().splitlines()
          )  # remove trailing `\r` in Windows
  
      return [
          tfds.core.SplitGenerator(
              name=tfds.Split.TRAIN,
              gen_kwargs={
                  "archive": dl_manager.iter_archive(train_path),
                  "subset": subset,
              },
          ),
          tfds.core.SplitGenerator(
              name=tfds.Split.VALIDATION,
              gen_kwargs={
                  "archive": dl_manager.iter_archive(val_path),
                  "validation_labels": imagenet_common.get_validation_labels(
                      val_path
                  ),
              },
          ),
      ]
  
file_path: datasets/tensorflow_datasets/datasets/imagenet2012_subset/imagenet2012_subset_dataset_builder.py
imports: import io
  import os
  from etils import epath
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  from tensorflow_datasets.datasets.imagenet2012 import imagenet2012_dataset_builder
  from tensorflow_datasets.datasets.imagenet2012 import imagenet_common
  import tensorflow_datasets.public_api
label_desc: Use image node_id 2 for calling the Builder obj's underlying member method code with example usage: obj._split_generators(dl_manager) and returns: list