class_docstr: Implementation of Completeness test by Kindermans et al., 2017.
  
  To test for input invariance, we add a constant shift to the input data and a mean shift to the model bias,
  so that the output of the original model on the original data is equal to the output of the changed model
  on the shifted data. The metric returns True if batch attributions stayed unchanged too. Currently only
  supporting constant values for the shift.
  
  References:
      Pieter-Jan Kindermans et al.: "The (Un)reliability of Saliency Methods." Explainable AI (2019): 267-280
  
  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.
class_docstr_tok: ["Implementation","of","Completeness","test","by","Kindermans","et","al.",",","2017",".","To","test","for","input","invariance",",","we","add","a","constant","shift","to","the","input","data","and","a","mean","shift","to","the","model","bias",",","so","that","the","output","of","the","original","model","on","the","original","data","is","equal","to","the","output","of","the","changed","model","on","the","shifted","data",".","The","metric","returns","True","if","batch","attributions","stayed","unchanged","too",".","Currently","only","supporting","constant","values","for","the","shift",".","References",":","Pieter-Jan","Kindermans","et","al",".",":","``","The","(","Un",")","reliability","of","Saliency","Methods",".","''","Explainable","AI","(","2019",")",":","267-280","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","."]
docstr: Parameters
  ----------
  abs: boolean
      Indicates whether absolute operation is applied on the attribution, default=False.
  normalise: boolean
      Indicates whether normalise operation is applied on the attribution, default=False.
  normalise_func: callable
      Attribution normalisation function applied in case normalise=True.
      If normalise_func=None, the default value is used, default=normalise_by_max.
  normalise_func_kwargs: dict
      Keyword arguments to be passed to normalise_func on call, default={}.
  input_shift: float, int
      The value used to shift the input and the model bias as per the paper, default=-1.
  perturb_func_kwargs: dict
      Keyword arguments to be passed to perturb_func, default={}.
  return_aggregate: boolean
      Indicates if an aggregated score should be produced over all instances.
  aggregate_func: callable
      A Callable to aggregate the scores per instance to one float.
  default_plot_func: callable
      Callable that plots the metrics result.
  disable_warnings: boolean
      Indicates whether the warnings are printed, default=False.
  display_progressbar: boolean
      Indicates whether a tqdm-progress-bar is printed, default=False.
  kwargs: optional
      Keyword arguments.
docstr_tok: ["Parameters","--","--","--","--","--","abs",":","boolean","Indicates","whether","absolute","operation","is","applied","on","the","attribution",",","default=False",".","normalise",":","boolean","Indicates","whether","normalise","operation","is","applied","on","the","attribution",",","default=False",".","normalise_func",":","callable","Attribution","normalisation","function","applied","in","case","normalise=True",".","If","normalise_func=None",",","the","default","value","is","used",",","default=normalise_by_max",".","normalise_func_kwargs",":","dict","Keyword","arguments","to","be","passed","to","normalise_func","on","call",",","default=","{","}",".","input_shift",":","float",",","int","The","value","used","to","shift","the","input","and","the","model","bias","as","per","the","paper",",","default=-1",".","perturb_func_kwargs",":","dict","Keyword","arguments","to","be","passed","to","perturb_func",",","default=","{","}",".","return_aggregate",":","boolean","Indicates","if","an","aggregated","score","should","be","produced","over","all","instances",".","aggregate_func",":","callable","A","Callable","to","aggregate","the","scores","per","instance","to","one","float",".","default_plot_func",":","callable","Callable","that","plots","the","metrics","result",".","disable_warnings",":","boolean","Indicates","whether","the","warnings","are","printed",",","default=False",".","display_progressbar",":","boolean","Indicates","whether","a","tqdm-progress-bar","is","printed",",","default=False",".","kwargs",":","optional","Keyword","arguments","."]
code: def __init__(
      self,
      abs: bool = False,
      normalise: bool = False,
      normalise_func: Optional[
          Callable[[np.ndarray], np.ndarray]
      ] = None,
      normalise_func_kwargs: Optional[Dict[str, Any]] = None,
      input_shift: Union[int, float] = -1,
      perturb_func: Optional[Callable] = None,
      perturb_func_kwargs: Optional[Dict[str, Any]] = None,
      return_aggregate: bool = False,
      aggregate_func: Optional[Callable] = None,
      default_plot_func: Optional[Callable] = None,
      disable_warnings: bool = False,
      display_progressbar: bool = False,
      **kwargs,
  ):
      """
      Parameters
      ----------
      abs: boolean
          Indicates whether absolute operation is applied on the attribution, default=False.
      normalise: boolean
          Indicates whether normalise operation is applied on the attribution, default=False.
      normalise_func: callable
          Attribution normalisation function applied in case normalise=True.
          If normalise_func=None, the default value is used, default=normalise_by_max.
      normalise_func_kwargs: dict
          Keyword arguments to be passed to normalise_func on call, default={}.
      input_shift: float, int
          The value used to shift the input and the model bias as per the paper, default=-1.
      perturb_func_kwargs: dict
          Keyword arguments to be passed to perturb_func, default={}.
      return_aggregate: boolean
          Indicates if an aggregated score should be produced over all instances.
      aggregate_func: callable
          A Callable to aggregate the scores per instance to one float.
      default_plot_func: callable
          Callable that plots the metrics result.
      disable_warnings: boolean
          Indicates whether the warnings are printed, default=False.
      display_progressbar: boolean
          Indicates whether a tqdm-progress-bar is printed, default=False.
      kwargs: optional
          Keyword arguments.
      """
      if normalise:
          warn.warn_normalise_operation(word="not ")
  
      if abs:
          warn.warn_absolute_operation(word="not ")
  
      super().__init__(
          abs=abs,
          normalise=normalise,
          normalise_func=normalise_func,
          normalise_func_kwargs=normalise_func_kwargs,
          return_aggregate=return_aggregate,
          aggregate_func=aggregate_func,
          default_plot_func=default_plot_func,
          display_progressbar=display_progressbar,
          disable_warnings=disable_warnings,
          **kwargs,
      )
  
      if perturb_func is None:
          perturb_func = baseline_replacement_by_shift
  
      self.perturb_func = make_perturb_func(
          perturb_func, perturb_func_kwargs, input_shift=input_shift
      )
  
      # Asserts and warnings.
      if not self.disable_warnings:
          warn.warn_parameterisation(
              metric_name=self.__class__.__name__,
              sensitive_params="input shift 'input_shift'",
              citation=(
                  "Kindermans Pieter-Jan, Hooker Sarah, Adebayo Julius, Alber Maximilian, Schütt Kristof T., "
                  "Dähne Sven, Erhan Dumitru and Kim Been. 'THE (UN)RELIABILITY OF SALIENCY METHODS' Article (2017)."
              ),
          )
  
file_path: Quantus/quantus/metrics/axiomatic/input_invariance.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  from quantus.functions.perturb_func import baseline_replacement_by_shift, perturb_batch
  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.helpers.perturbation_utils import make_perturb_func
  from quantus.metrics.base import Metric
label_desc: Use image node_id 1 to create a new InputInvariance object from inherited base classes: Metric with example: obj = InputInvariance(abs, normalise, normalise_func, normalise_func_kwargs, input_shift, perturb_func, perturb_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)