class_docstr: Interface defining Metrics' API.
docstr: Initialise the Metric base class.
  
  Each of the defined metrics in Quantus, inherits from Metric base class.
  
  A child metric can benefit from the following class methods:
  - __call__(): Will call general_preprocess(), apply evaluate_instance() on each
                instance and finally call custom_preprocess().
                To use this method the child Metric needs to implement
                evaluate_instance().
  - general_preprocess(): Prepares all necessary data structures for evaluation.
                          Will call custom_preprocess() at the end.
  
  The content of evaluation_scores will be appended to all_evaluation_scores (list) at the end of
  the evaluation call.
  
  Parameters
  ----------
  abs: boolean
      Indicates whether absolute operation is applied on the attribution.
  normalise: boolean
      Indicates whether normalise operation is applied on the attribution.
  normalise_func: callable
      Attribution normalisation function applied in case normalise=True.
  normalise_func_kwargs: dict
      Keyword arguments to be passed to normalise_func on call.
  return_aggregate: boolean
      Indicates if an aggregated score should be computed over all instances.
  aggregate_func: callable
      Callable that aggregates the scores given an evaluation call.
  default_plot_func: callable
      Callable that plots the metrics result.
  disable_warnings: boolean
      Indicates whether the warnings are printed.
  display_progressbar: boolean
      Indicates whether a tqdm-progress-bar is printed.
  kwargs: optional
      Keyword arguments.
docstr_tok: ["Initialise","the","Metric","base","class",".","Each","of","the","defined","metrics","in","Quantus",",","inherits","from","Metric","base","class",".","A","child","metric","can","benefit","from","the","following","class","methods",":","-","__call__","(",")",":","Will","call","general_preprocess","(",")",",","apply","evaluate_instance","(",")","on","each","instance","and","finally","call","custom_preprocess","(",")",".","To","use","this","method","the","child","Metric","needs","to","implement","evaluate_instance","(",")",".","-","general_preprocess","(",")",":","Prepares","all","necessary","data","structures","for","evaluation",".","Will","call","custom_preprocess","(",")","at","the","end",".","The","content","of","evaluation_scores","will","be","appended","to","all_evaluation_scores","(","list",")","at","the","end","of","the","evaluation","call",".","Parameters","--","--","--","--","--","abs",":","boolean","Indicates","whether","absolute","operation","is","applied","on","the","attribution",".","normalise",":","boolean","Indicates","whether","normalise","operation","is","applied","on","the","attribution",".","normalise_func",":","callable","Attribution","normalisation","function","applied","in","case","normalise=True",".","normalise_func_kwargs",":","dict","Keyword","arguments","to","be","passed","to","normalise_func","on","call",".","return_aggregate",":","boolean","Indicates","if","an","aggregated","score","should","be","computed","over","all","instances",".","aggregate_func",":","callable","Callable","that","aggregates","the","scores","given","an","evaluation","call",".","default_plot_func",":","callable","Callable","that","plots","the","metrics","result",".","disable_warnings",":","boolean","Indicates","whether","the","warnings","are","printed",".","display_progressbar",":","boolean","Indicates","whether","a","tqdm-progress-bar","is","printed",".","kwargs",":","optional","Keyword","arguments","."]
code: def __init__(
      self,
      abs: bool,
      normalise: bool,
      normalise_func: Optional[Callable],
      normalise_func_kwargs: Optional[Dict[str, Any]],
      return_aggregate: bool,
      aggregate_func: Callable,
      default_plot_func: Optional[Callable],
      disable_warnings: bool,
      display_progressbar: bool,
      **kwargs,
  ):
      """
      Initialise the Metric base class.
  
      Each of the defined metrics in Quantus, inherits from Metric base class.
  
      A child metric can benefit from the following class methods:
      - __call__(): Will call general_preprocess(), apply evaluate_instance() on each
                    instance and finally call custom_preprocess().
                    To use this method the child Metric needs to implement
                    evaluate_instance().
      - general_preprocess(): Prepares all necessary data structures for evaluation.
                              Will call custom_preprocess() at the end.
  
      The content of evaluation_scores will be appended to all_evaluation_scores (list) at the end of
      the evaluation call.
  
      Parameters
      ----------
      abs: boolean
          Indicates whether absolute operation is applied on the attribution.
      normalise: boolean
          Indicates whether normalise operation is applied on the attribution.
      normalise_func: callable
          Attribution normalisation function applied in case normalise=True.
      normalise_func_kwargs: dict
          Keyword arguments to be passed to normalise_func on call.
      return_aggregate: boolean
          Indicates if an aggregated score should be computed over all instances.
      aggregate_func: callable
          Callable that aggregates the scores given an evaluation call.
      default_plot_func: callable
          Callable that plots the metrics result.
      disable_warnings: boolean
          Indicates whether the warnings are printed.
      display_progressbar: boolean
          Indicates whether a tqdm-progress-bar is printed.
      kwargs: optional
          Keyword arguments.
      """
  
      if aggregate_func is None:
          aggregate_func = np.mean
  
      if normalise_func is None:
          normalise_func = normalise_by_max
  
      if normalise_func_kwargs is not None:
          normalise_func = functools.partial(
              normalise_func, **normalise_func_kwargs
          )
  
      # Run deprecation warnings.
      warn.deprecation_warnings(kwargs)
      warn.check_kwargs(kwargs)
  
      self.abs = abs
      self.normalise = normalise
      self.return_aggregate = return_aggregate
      self.aggregate_func = aggregate_func
      self.normalise_func = normalise_func
  
      self.default_plot_func = default_plot_func
  
      # We need underscores here to avoid conflict with @property descriptor.
      self._disable_warnings = disable_warnings
      self._display_progressbar = display_progressbar
  
      self.a_axes = None
  
      self.evaluation_scores = []
      self.all_evaluation_scores = []
  
imports: from __future__ import annotations
  import functools
  import logging
  import os
  import sys
  from abc import abstractmethod
  from typing import Any, Callable, ClassVar, Dict, Generator, Generic, Sequence, Set, TypeVar, Optional, Union, TYPE_CHECKING, no_type_check
  import matplotlib.pyplot
  import numpy
  from sklearn.utils import gen_batches
  from tqdm.auto import tqdm
  from quantus.helpers import asserts, utils, warn
  from quantus.functions.normalise_func import normalise_by_max
  from quantus.helpers.enums import DataType, EvaluationCategory, ModelType, ScoreDirection
  from quantus.helpers.model.model_interface import ModelInterface
label_desc: Use image node_id 1 to create a new Metric object from inherited base classes: Generic with example: obj = Metric(abs, normalise, normalise_func, normalise_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)