class_docstr: Implementation of the Consistency metric which measures the expected local consistency, i.e., the probability
  of the prediction label for a given datapoint coinciding with the prediction labels of other data points that
  the same explanation is being attributed to. For example, if the explanation of a given image is "contains zebra",
  the local consistency metric measures the probability a different image that the explanation "contains zebra" is
  being attributed to having the same prediction label.
  
  Assumptions:
      - A used-defined discreization function is used to discretize continuous explanation spaces.
  
  References:
       1) Sanjoy Dasgupta et al.: "Framework for Evaluating Faithfulness of Local
          Explanations." ICML (2022): 4794-4815.
  
  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","Consistency","metric","which","measures","the","expected","local","consistency",",","i.e.",",","the","probability","of","the","prediction","label","for","a","given","datapoint","coinciding","with","the","prediction","labels","of","other","data","points","that","the","same","explanation","is","being","attributed","to",".","For","example",",","if","the","explanation","of","a","given","image","is","``","contains","zebra","''",",","the","local","consistency","metric","measures","the","probability","a","different","image","that","the","explanation","``","contains","zebra","''","is","being","attributed","to","having","the","same","prediction","label",".","Assumptions",":","-","A","used-defined","discreization","function","is","used","to","discretize","continuous","explanation","spaces",".","References",":","1",")","Sanjoy","Dasgupta","et","al",".",":","``","Framework","for","Evaluating","Faithfulness","of","Local","Explanations",".","''","ICML","(","2022",")",":","4794-4815",".","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
  ----------
  a: np.ndarray
      The explanation to be evaluated on an instance-basis.
  i: int
      The index of the current instance.
  a_label: np.ndarray
      The discretised attribution labels.
  y_pred_classes: np,ndarray
      The class predictions of the complete input dataset.
  
  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","--","--","--","--","--","a",":","np.ndarray","The","explanation","to","be","evaluated","on","an","instance-basis",".","i",":","int","The","index","of","the","current","instance",".","a_label",":","np.ndarray","The","discretised","attribution","labels",".","y_pred_classes",":","np",",","ndarray","The","class","predictions","of","the","complete","input","dataset",".","Returns","--","--","--","-","float","The","evaluation","results","."]
code: def evaluate_instance(
      a: np.ndarray,
      i: int,
      a_label: np.ndarray,
      y_pred_classes: np.ndarray,
  ) -> float:
      """
      Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
      Parameters
      ----------
      a: np.ndarray
          The explanation to be evaluated on an instance-basis.
      i: int
          The index of the current instance.
      a_label: np.ndarray
          The discretised attribution labels.
      y_pred_classes: np,ndarray
          The class predictions of the complete input dataset.
  
      Returns
      -------
      float
          The evaluation results.
      """
      # Metric logic.
      pred_a = y_pred_classes[i]
      same_a = np.argwhere(a == a_label).flatten()
      diff_a = same_a[same_a != i]
      pred_same_a = y_pred_classes[diff_a]
  
      if len(same_a) == 0:
          return 0
      return np.sum(pred_same_a == pred_a) / len(diff_a)
  
file_path: Quantus/quantus/metrics/robustness/consistency.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional, no_type_check
  import numpy
  from quantus.functions.discretise_func import top_n_sign
  from quantus.helpers.model.model_interface import ModelInterface
  from quantus.helpers import warn
  from quantus.helpers.enums import DataType, EvaluationCategory, ModelType, ScoreDirection
  from quantus.metrics.base import Metric
label_desc: Use image node_id 3 for calling the Consistency obj's underlying member method code with example usage: obj.evaluate_instance(a, i, a_label, y_pred_classes) and returns: unknown, int