code: def _generate_examples(self, data_dir):
      
      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 image, label in zip(images, labels):
        yield {
            'image': image,
            'label': label,
        }
docs: 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.