class_docstr: Perturbation of pixels based on analysis result.
  
  :param perturbation_function:
      Defines the function with which the samples are perturbated.
      Can be a function or a string that defines a predefined perturbation function.
  :type perturbation_function:
      function or callable or str
  :param num_perturbed_regions:
      Number of regions to be perturbed.
  :type num_perturbed_regions:
      int
  :param reduce_function:
      Function to reduce the analysis result to one channel,
      e.g. mean or max function.
  :type reduce_function:
      function or callable
  :param aggregation_function:
      Function to aggregate the analysis over subregions.
  :type aggregation_function:
      function or callable
  :param pad_mode:
      How to pad if the image cannot be subdivided into an integer number of regions.
      As in numpy.pad.
  :type pad_mode:
      str or function or callable
  :param in_place:
      If true, the perturbations are performed in place,
      i.e. the input samples are modified.
  :type in_place:
      bool
  :param value_range:
      Minimal and maximal value after perturbation as a tuple:
      (min_val, max_val). The input is clipped to this range
  :type value_range: tuple
docstr: :param x: Batch of images.
  :type x: numpy.ndarray
  :param analysis: Analysis of this batch.
  :type analysis: numpy.ndarray
  :return: Batch of perturbated images
  :rtype: numpy.ndarray
docstr_tok: [":","param","x",":","Batch","of","images",".",":","type","x",":","numpy.ndarray",":","param","analysis",":","Analysis","of","this","batch",".",":","type","analysis",":","numpy.ndarray",":","return",":","Batch","of","perturbated","images",":","rtype",":","numpy.ndarray"]
code: def perturbate_on_batch(self, x, analysis):
      """
      :param x: Batch of images.
      :type x: numpy.ndarray
      :param analysis: Analysis of this batch.
      :type analysis: numpy.ndarray
      :return: Batch of perturbated images
      :rtype: numpy.ndarray
      """
      # Internally use channels_first (BCHW) only:
      if kbackend.image_data_format() == "channels_last":
          x = np.moveaxis(x, 3, 1)
          analysis = np.moveaxis(analysis, 3, 1)
      if not self.in_place:
          x = np.copy(x)
      assert analysis.shape == x.shape, analysis.shape
      original_shape = x.shape
      # reduce the analysis along channel axis -> n x 1 x h x w
      analysis = self.reduce_function(analysis, axis=1, keepdims=True)
      assert analysis.shape == (
          x.shape[0],
          1,
          x.shape[2],
          x.shape[3],
      ), analysis.shape
  
      padding = not np.all(
          np.array(analysis.shape[2:]) % self.region_shape == 0
      )
      if padding:
          analysis, _pad_shape_before_analysis = self._pad(analysis)
          x, pad_shape_before_x = self._pad(x)
      aggregated_regions = self._aggregate_regions(analysis)
  
      # Compute perturbation mask
      # (mask with ones where the input should be perturbated, zeros otherwise)
      ranks = self._compute_region_ordering(aggregated_regions)
      perturbation_mask_regions = self._compute_perturbation_mask(
          ranks, self.num_perturbed_regions
      )
      # Perturbate each region
      x_perturbated = self._perturbate_regions(
          x, perturbation_mask_regions
      )
  
      # Crop the original image region to remove the padding
      if padding:
          x_perturbated = x_perturbated[
              :,
              :,
              pad_shape_before_x[0] : pad_shape_before_x[0]
              + original_shape[2],
              pad_shape_before_x[1] : pad_shape_before_x[1]
              + original_shape[3],
          ]
  
      if kbackend.image_data_format() == "channels_last":
          x_perturbated = np.moveaxis(x_perturbated, 1, 3)
          x = np.moveaxis(x, 1, 3)
          analysis = np.moveaxis(analysis, 1, 3)
      return x_perturbated
  
imports: from __future__ import annotations
  import time
  import warnings
  import numpy
  import tensorflow.keras.backend
  import tensorflow.keras.utils
  import innvestigate.utils.sequence
label_desc: Use image node_id 10 for calling the Perturbation obj's underlying member method code with example usage: obj.perturbate_on_batch(x, analysis) and returns: x_perturbated