class_docstr: Implementation of the Model Parameter Randomisation Test (MPRT) by Adebayo et al., 2018.
  
  The MPRT measures the distance between the original attribution and a newly computed
  attribution throughout the process of cascadingly/ independently randomizing the model
  parameters of one layer at a time.
  
  Assumptions:
      - In the original paper multiple distance measures are taken: Spearman rank correlation (with and without abs),
      HOG and SSIM. We have set Spearman as the default value.
  
  References:
      1) Julius Adebayo et al.: "Sanity Checks for Saliency Maps." NeurIPS (2018): 9525-9536.
  
  Attributes:
      -  _name: The name of the metric.
      - _data_applicability: The data types that the metric implementation currently supports.
      - _models: The model types that this metric can work with.
      - score_direction: How to interpret the scores, whether higher/ lower values are considered better.
      - evaluation_category: What property/ explanation quality that this metric measures.
docstr: Implementation of custom_preprocess_batch.
  
  Parameters
  ----------
  model: torch.nn.Module, tf.keras.Model
      A torch or tensorflow model e.g., torchvision.models that is subject to explanation.
  x_batch: np.ndarray
      A np.ndarray which contains the input data that are explained.
  y_batch: np.ndarray
      A np.ndarray which contains the output labels that are explained.
  a_batch: np.ndarray, optional
      A np.ndarray which contains pre-computed attributions i.e., explanations.
  kwargs:
      Unused.
  Returns
  -------
  None
docstr_tok: ["Implementation","of","custom_preprocess_batch",".","Parameters","--","--","--","--","--","model",":","torch.nn.Module",",","tf.keras.Model","A","torch","or","tensorflow","model","e.g.",",","torchvision.models","that","is","subject","to","explanation",".","x_batch",":","np.ndarray","A","np.ndarray","which","contains","the","input","data","that","are","explained",".","y_batch",":","np.ndarray","A","np.ndarray","which","contains","the","output","labels","that","are","explained",".","a_batch",":","np.ndarray",",","optional","A","np.ndarray","which","contains","pre-computed","attributions","i.e.",",","explanations",".","kwargs",":","Unused",".","Returns","--","--","--","-","None"]
code: def custom_preprocess(
      self,
      model: ModelInterface,
      x_batch: np.ndarray,
      y_batch: np.ndarray,
      a_batch: Optional[np.ndarray],
      **kwargs,
  ) -> Optional[Dict[str, np.ndarray]]:
      """
      Implementation of custom_preprocess_batch.
  
      Parameters
      ----------
      model: torch.nn.Module, tf.keras.Model
          A torch or tensorflow model e.g., torchvision.models that is subject to explanation.
      x_batch: np.ndarray
          A np.ndarray which contains the input data that are explained.
      y_batch: np.ndarray
          A np.ndarray which contains the output labels that are explained.
      a_batch: np.ndarray, optional
          A np.ndarray which contains pre-computed attributions i.e., explanations.
      kwargs:
          Unused.
      Returns
      -------
      None
      """
      # Additional explain_func assert, as the one in general_preprocess()
      # won't be executed when a_batch != None.
      asserts.assert_explain_func(explain_func=self.explain_func)
      if a_batch is not None:  # Just to silence mypy warnings
          return None
  
      a_batch_chunks = []
      for a_chunk in self.generate_explanations(
          model, x_batch, y_batch, self.batch_size
      ):
          a_batch_chunks.extend(a_chunk)
      return dict(a_batch=np.asarray(a_batch_chunks))
  
imports: import sys
  import warnings
  from typing import Any, Callable, Collection, Dict, List, Optional, Union, Tuple, Generator, Iterable
  import numpy
  from tqdm.auto import tqdm
  from sklearn.utils import gen_batches
  from quantus.functions.similarity_func import correlation_spearman
  from quantus.helpers import asserts, warn
  from quantus.helpers.enums import DataType, EvaluationCategory, ModelType, ScoreDirection
  from quantus.helpers.model.model_interface import ModelInterface
  from quantus.metrics.base import Metric
label_desc: Use image node_id 6 for calling the MPRT obj's underlying member method code with example usage: obj.custom_preprocess(model, x_batch, y_batch, a_batch) and returns: dict, None