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: Compute additional arguments required for Consistency on batch-level.
docstr_tok: ["Compute","additional","arguments","required","for","Consistency","on","batch-level","."]
code: def custom_batch_preprocess(
      self,
      model: ModelInterface,
      x_batch: np.ndarray,
      a_batch: np.ndarray,
      **kwargs,
  ) -> Dict[str, np.ndarray]:
      """Compute additional arguments required for Consistency on batch-level."""
      x_input = model.shape_input(
          x_batch, x_batch[0].shape, channel_first=True, batched=True
      )
      a_batch_flat = a_batch.reshape(a_batch.shape[0], -1)
  
      a_labels = np.array(list(map(self.discretise_func, a_batch_flat)))
  
      y_pred_classes = np.argmax(
          model.predict(x_input), axis=1
      ).flatten()
  
      return {
          "i_batch": np.arange(x_batch.shape[0]),
          "a_label_batch": a_labels,
          "y_pred_classes": y_pred_classes,
      }
  
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 4 for calling the Consistency obj's underlying member method code with example usage: obj.custom_batch_preprocess(model, x_batch, a_batch) and returns: dict