Generate corrupted imagenet validation data.

    Apply corruptions to the raw images according to self.corruption_type.

    Args:
      archive: an iterator for the raw dataset.
      labels: a dictionary that maps the file names to imagenet labels.

    Yields:
      dictionary with the file name, an image file objective, and label of each
      imagenet validation data.

def _generate_examples_validation(self, archive, labels):
    """Generate corrupted imagenet validation data.

    Apply corruptions to the raw images according to self.corruption_type.

    Args:
      archive: an iterator for the raw dataset.
      labels: a dictionary that maps the file names to imagenet labels.

    Yields:
      dictionary with the file name, an image file objective, and label of each
      imagenet validation data.
    """
    # Get the current random seeds.
    numpy_st0 = np.random.get_state()
    # Set new random seeds.
    np.random.seed(135)
    logging.warning('Overwriting cv2 RNG seed.')
    tfds.core.lazy_imports.cv2.setRNGSeed(357)

    for example in super(Imagenet2012Corrupted,
                         self)._generate_examples_validation(archive, labels):
      with tf.Graph().as_default():
        tf_img = tf.image.decode_jpeg(example['image'].read(), channels=3)
        image_np = tfds.as_numpy(tf_img)
      example['image'] = self._get_corrupted_example(image_np)
      yield example
    # Reset the seeds back to their original values.
    np.random.set_state(numpy_st0)