class_docstr: Implementation of Focus evaluation strategy by Arias et. al. 2022
  
  The Focus is computed through mosaics of instances from different classes, and the explanations these generate.
  Each mosaic contains four images: two images belonging to the target class (the specific class the feature
  attribution method is expected to explain) and the other two are chosen randomly from the rest of classes.
  Thus, the Focus estimates the reliability of feature attribution method’s output as the probability of the sampled
  pixels lying on an image of the target class of the mosaic. This is equivalent to the proportion
  of positive relevance lying on those images.
  
  References:
      1) Anna Arias-Duart et al.: "Focus! Rating XAI Methods
      and Finding Biases" FUZZ-IEEE (2022): 1-8.
  
  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","Focus","evaluation","strategy","by","Arias","et",".","al",".","2022","The","Focus","is","computed","through","mosaics","of","instances","from","different","classes",",","and","the","explanations","these","generate",".","Each","mosaic","contains","four","images",":","two","images","belonging","to","the","target","class","(","the","specific","class","the","feature","attribution","method","is","expected","to","explain",")","and","the","other","two","are","chosen","randomly","from","the","rest","of","classes",".","Thus",",","the","Focus","estimates","the","reliability","of","feature","attribution","method","\u2019","s","output","as","the","probability","of","the","sampled","pixels","lying","on","an","image","of","the","target","class","of","the","mosaic",".","This","is","equivalent","to","the","proportion","of","positive","relevance","lying","on","those","images",".","References",":","1",")","Anna","Arias-Duart","et","al",".",":","``","Focus","!","Rating","XAI","Methods","and","Finding","Biases","''","FUZZ-IEEE","(","2022",")",":","1-8",".","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: 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=True.
  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={}.
  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, 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=True",".","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=","{","}",".","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",",","default=False",".","display_progressbar",":","boolean","Indicates","whether","a","tqdm-progress-bar","is","printed",",","default=False",".","kwargs",":","optional","Keyword","arguments","."]
code: def __init__(
      self,
      mosaic_shape: Optional[Any] = None,
      abs: bool = False,
      normalise: bool = True,
      normalise_func: Optional[
          Callable[[np.ndarray], np.ndarray]
      ] = None,
      normalise_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=True.
      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={}.
      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, default=False.
      display_progressbar: boolean
          Indicates whether a tqdm-progress-bar is printed, default=False.
      kwargs: optional
          Keyword arguments.
      """
      if default_plot_func is None:
          default_plot_func = plotting.plot_focus
  
      # Save metric-specific attributes.
      self.mosaic_shape = mosaic_shape
  
      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,
      )
  
      # Asserts and warnings.
      if not self.disable_warnings:
          warn.warn_parameterisation(
              metric_name=self.__class__.__name__,
              sensitive_params=(
                  "no parameter. No parameters means nothing to be sensitive on. "
                  "Note, however, that Focus only works with image data and "
                  "a 'p_batch' must be provided when calling the metric to "
                  "represent the positions of the target class"
              ),
              citation=(
                  "Arias-Duart, Anna, et al. 'Focus! Rating XAI Methods and Finding Biases.'"
                  "arXiv:2109.15035 (2022)"
              ),
          )
  
file_path: Quantus/quantus/metrics/localisation/focus.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  from quantus.helpers import plotting, 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 1 to create a new Focus object from inherited base classes: Metric with example: obj = Focus(mosaic_shape, abs, normalise, normalise_func, normalise_func_kwargs, return_aggregate, aggregate_func, default_plot_func, disable_warnings, display_progressbar)