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: Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
  Parameters
  ----------
  model: ModelInterface
      A ModelInteface that is subject to explanation.
  x: np.ndarray
      The input to be evaluated on an instance-basis.
  y: np.ndarray
      The output to be evaluated on an instance-basis.
  a: np.ndarray
      The explanation to be evaluated on an instance-basis.
  s: np.ndarray
      The segmentation to be evaluated on an instance-basis.
  a_perturbed: np.ndarray
      The perturbed attributions.
  
  Returns
  -------
  float
      The evaluation results.
docstr_tok: ["Evaluate","instance","gets","model","and","data","for","a","single","instance","as","input","and","returns","the","evaluation","result",".","Parameters","--","--","--","--","--","model",":","ModelInterface","A","ModelInteface","that","is","subject","to","explanation",".","x",":","np.ndarray","The","input","to","be","evaluated","on","an","instance-basis",".","y",":","np.ndarray","The","output","to","be","evaluated","on","an","instance-basis",".","a",":","np.ndarray","The","explanation","to","be","evaluated","on","an","instance-basis",".","s",":","np.ndarray","The","segmentation","to","be","evaluated","on","an","instance-basis",".","a_perturbed",":","np.ndarray","The","perturbed","attributions",".","Returns","--","--","--","-","float","The","evaluation","results","."]
code: def evaluate_instance(
      self,
      model: ModelInterface,
      x: Optional[np.ndarray],
      y: Optional[np.ndarray],
      a: Optional[np.ndarray],
      s: Optional[np.ndarray],
      a_perturbed: Optional[np.ndarray] = None,
  ) -> float:
      """
      Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
      Parameters
      ----------
      model: ModelInterface
          A ModelInteface that is subject to explanation.
      x: np.ndarray
          The input to be evaluated on an instance-basis.
      y: np.ndarray
          The output to be evaluated on an instance-basis.
      a: np.ndarray
          The explanation to be evaluated on an instance-basis.
      s: np.ndarray
          The segmentation to be evaluated on an instance-basis.
      a_perturbed: np.ndarray
          The perturbed attributions.
  
      Returns
      -------
      float
          The evaluation results.
      """
      # Flatten the arrays for comparison and check constancy.
      a_flat = a.flatten()
      a_perturbed_flat = a_perturbed.flatten()
  
      try:
          return self.similarity_func(a_perturbed_flat, a_flat)
      except Exception as e:
          print(
              f"Encountered exception: {e} in similarity measure calculation"
          )
          warnings.warn(
              "Setting similarity output to 1.",
              UserWarning,
          )
          return 1.0
  
      # Compute similarity measure.
      return self.similarity_func(a_perturbed_flat, a_flat)
  
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 5 for calling the SmoothMPRT obj's underlying member method code with example usage: obj.evaluate_instance(model, x, y, a, s, a_perturbed) and returns: self, self, int