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
code: def _perturbate_regions(self, x, perturbation_mask_regions):
      # Perturbate every region in tensor.
      # A single region (at region_x, region_y in sample)
      # should be in mask[sample, channel, region_x, :, region_y, :]
      n_channels = x.shape[1]
      xp = self._reshape_to_regions(x)  # perturbed output
      for sample_idx, channel_idx, region_row, region_col in np.ndindex(
          perturbation_mask_regions.shape
      ):
          region_mask = perturbation_mask_regions[
              sample_idx, channel_idx, region_row, region_col
          ]
          if region_mask:
              for c in range(n_channels):
                  region = xp[
                      sample_idx, c, region_row, :, region_col, :
                  ]
                  xp[
                      sample_idx, c, region_row, :, region_col, :
                  ] = self.perturbation_function(region)
  
      if self.value_range is not None:
          np.clip(xp, self.value_range[0], self.value_range[1], xp)
      xp = self._reshape_region_pixels(xp, x.shape)
      return xp
  
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 9 for calling the Perturbation obj's underlying member method code with example usage: obj._perturbate_regions(x, perturbation_mask_regions) and returns: xp