class_docstr: Corrupted Cifar10 dataset.
class_docstr_tok: ["Corrupted","Cifar10","dataset","."]
docstr: Generate corrupted Cifar10 test data.
  
  Apply corruptions to the raw images according to self.corruption_type.
  
  Args:
    data_dir: root directory of downloaded dataset
  
  Yields:
    dictionary with image file and label.
docstr_tok: ["Generate","corrupted","Cifar10","test","data",".","Apply","corruptions","to","the","raw","images","according","to","self.corruption_type",".","Args",":","data_dir",":","root","directory","of","downloaded","dataset","Yields",":","dictionary","with","image","file","and","label","."]
code: def _generate_examples(self, data_dir):
      """Generate corrupted Cifar10 test data.
  
      Apply corruptions to the raw images according to self.corruption_type.
  
      Args:
        data_dir: root directory of downloaded dataset
  
      Yields:
        dictionary with image file and label.
      """
      corruption = self.builder_config.corruption
      severity = self.builder_config.severity
  
      images_file = os.path.join(
          data_dir, _CORRUPTIONS_TO_FILENAMES[corruption]
      )
      labels_file = os.path.join(data_dir, _LABELS_FILENAME)
  
      with tf.io.gfile.GFile(labels_file, mode="rb") as f:
          labels = np.load(f)
  
      num_images = labels.shape[0] // 5
      # Labels are stacked 5 times so we can just read the first iteration
      labels = labels[:num_images]
  
      with tf.io.gfile.GFile(images_file, mode="rb") as f:
          images = np.load(f)
  
      # Slice images corresponding to correct severity level
      images = images[
          (severity - 1) * num_images : severity * num_images
      ]
  
      for i, (image, label) in enumerate(zip(images, labels)):
          yield i, {
              "image": image,
              "label": label,
          }
  
file_path: datasets/tensorflow_datasets/image_classification/cifar10_corrupted.py
imports: import os
  import numpy
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling the Cifar10Corrupted obj's underlying member method code with example usage: obj._generate_examples(data_dir) without return types