class_docstr: Implementation of the Smooth MPRT by Hedström et al., 2023.
  
  The Smooth Model Parameter Randomisation adds a "denoising" preprocessing step to the original MPRT,
  where the explanations are averaged over N noisy samples before the similarity between the original-
  and fully random model's explanations is measured.
  
  References:
      1) Hedström, Anna, et al. "Sanity Checks Revisited: An Exploration to Repair the Model Parameter
      Randomisation Test." XAI in Action: Past, Present, and Future Applications. 2023.
  
  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.
class_docstr_tok: ["Implementation","of","the","Smooth","MPRT","by","Hedstr\u00f6m","et","al.",",","2023",".","The","Smooth","Model","Parameter","Randomisation","adds","a","``","denoising","''","preprocessing","step","to","the","original","MPRT",",","where","the","explanations","are","averaged","over","N","noisy","samples","before","the","similarity","between","the","original-","and","fully","random","model","'s","explanations","is","measured",".","References",":","1",")","Hedstr\u00f6m",",","Anna",",","et","al",".","``","Sanity","Checks","Revisited",":","An","Exploration","to","Repair","the","Model","Parameter","Randomisation","Test",".","''","XAI","in","Action",":","Past",",","Present",",","and","Future","Applications",".","2023",".","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: Compute explanations, normalise and take absolute (if was configured so during metric initialization.)
  This method should primarily be used if you need to generate additional explanation
  in metrics body. It encapsulates typical for Quantus pre- and postprocessing approach.
  It will do few things:
      - call model.shape_input (if ModelInterface instance was provided)
      - unwrap model (if ModelInterface instance was provided)
      - add noise to input and call explain_func via explain_smooth_batch_numpy
      - expand attribution channel
      - (optionally) normalise a_batch
      - (optionally) take np.abs of a_batch
  
  Parameters
  -------
  model:
      A model that is subject to explanation.
  x_batch:
      A np.ndarray which contains the input data that are explained.
  y_batch:
      A np.ndarray which contains the output labels that are explained.
  kwargs: optional, dict
      List of hyperparameters.
  
  Returns
  -------
  a_batch:
      Batch of explanations ready to be evaluated.
docstr_tok: ["Compute","explanations",",","normalise","and","take","absolute","(","if","was","configured","so","during","metric","initialization",".",")","This","method","should","primarily","be","used","if","you","need","to","generate","additional","explanation","in","metrics","body",".","It","encapsulates","typical","for","Quantus","pre-","and","postprocessing","approach",".","It","will","do","few","things",":","-","call","model.shape_input","(","if","ModelInterface","instance","was","provided",")","-","unwrap","model","(","if","ModelInterface","instance","was","provided",")","-","add","noise","to","input","and","call","explain_func","via","explain_smooth_batch_numpy","-","expand","attribution","channel","-","(","optionally",")","normalise","a_batch","-","(","optionally",")","take","np.abs","of","a_batch","Parameters","--","--","--","-","model",":","A","model","that","is","subject","to","explanation",".","x_batch",":","A","np.ndarray","which","contains","the","input","data","that","are","explained",".","y_batch",":","A","np.ndarray","which","contains","the","output","labels","that","are","explained",".","kwargs",":","optional",",","dict","List","of","hyperparameters",".","Returns","--","--","--","-","a_batch",":","Batch","of","explanations","ready","to","be","evaluated","."]
code: def explain_smooth_batch(
      self,
      model: ModelInterface,
      x_batch: np.ndarray,
      y_batch: np.ndarray,
      **kwargs,
  ) -> np.ndarray:
      """
      Compute explanations, normalise and take absolute (if was configured so during metric initialization.)
      This method should primarily be used if you need to generate additional explanation
      in metrics body. It encapsulates typical for Quantus pre- and postprocessing approach.
      It will do few things:
          - call model.shape_input (if ModelInterface instance was provided)
          - unwrap model (if ModelInterface instance was provided)
          - add noise to input and call explain_func via explain_smooth_batch_numpy
          - expand attribution channel
          - (optionally) normalise a_batch
          - (optionally) take np.abs of a_batch
  
      Parameters
      -------
      model:
          A model that is subject to explanation.
      x_batch:
          A np.ndarray which contains the input data that are explained.
      y_batch:
          A np.ndarray which contains the output labels that are explained.
      kwargs: optional, dict
          List of hyperparameters.
  
      Returns
      -------
      a_batch:
          Batch of explanations ready to be evaluated.
      """
      if isinstance(model, ModelInterface):
          # Sometimes the model is our wrapper, but sometimes raw Keras/Torch model.
          x_batch = model.shape_input(
              x=x_batch,
              shape=x_batch.shape,
              channel_first=True,
              batched=True,
          )
          model = model.get_model()
  
      # Set noise.
      dims = tuple(range(1, x_batch.ndim))
      std = self.noise_magnitude * (
          x_batch.max(axis=dims, keepdims=True)
          - x_batch.min(axis=dims, keepdims=True)
      )
      a_batch_smooth = self.explain_smooth_batch_numpy(
          model=model,
          x_batch=x_batch,
          y_batch=y_batch,
          std=std,
          **kwargs,
      )
  
      a_batch_smooth = utils.expand_attribution_channel(
          a_batch_smooth, x_batch
      )
      asserts.assert_attributions(
          x_batch=x_batch, a_batch=a_batch_smooth
      )
  
      # Normalise and take absolute values of the attributions, if configured during metric instantiation.
      if self.normalise:
          a_batch_smooth = self.normalise_func(a_batch_smooth)
  
      if self.abs:
          a_batch_smooth = np.abs(a_batch_smooth)
  
      return a_batch_smooth
  
imports: import sys
  import warnings
  from typing import Any, Callable, Collection, Dict, List, Optional, Union, Tuple, Generator, Iterable
  from importlib import util
  import numpy
  import quantus
  from tqdm.auto import tqdm
  from sklearn.utils import gen_batches
  from scipy import stats
  from quantus.functions.similarity_func import correlation_spearman
  from quantus.helpers import asserts, warn, utils
  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 10 for calling the SmoothMPRT obj's underlying member method code with example usage: obj.explain_smooth_batch(model, x_batch, y_batch) and returns: a_batch_smooth