class_docstr: Implementation of the Random Logit Metric by Sixt et al., 2020.
  
  The Random Logit Metric computes the distance between the original explanation and a reference explanation of
  a randomly chosen non-target class.
  
  References:
      1) Leon Sixt et al.: "When Explanations Lie: Why Many Modified BP
      Attributions Fail." ICML (2020): 9046-9057.
  
  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","Random","Logit","Metric","by","Sixt","et","al.",",","2020",".","The","Random","Logit","Metric","computes","the","distance","between","the","original","explanation","and","a","reference","explanation","of","a","randomly","chosen","non-target","class",".","References",":","1",")","Leon","Sixt","et","al",".",":","``","When","Explanations","Lie",":","Why","Many","Modified","BP","Attributions","Fail",".","''","ICML","(","2020",")",":","9046-9057",".","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
  ----------
  model: ModelInterface
      A ModelInteface that is subject to explanation.
  x: np.ndarray
      The input to be evaluated on an instance-basis.
  y: np.ndarray
      The output to be evaluated on an instance-basis.
  a: np.ndarray
      The explanation to be evaluated on an instance-basis.
  
  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","--","--","--","--","--","model",":","ModelInterface","A","ModelInteface","that","is","subject","to","explanation",".","x",":","np.ndarray","The","input","to","be","evaluated","on","an","instance-basis",".","y",":","np.ndarray","The","output","to","be","evaluated","on","an","instance-basis",".","a",":","np.ndarray","The","explanation","to","be","evaluated","on","an","instance-basis",".","Returns","--","--","--","-","float","The","evaluation","results","."]
code: def evaluate_instance(
      self,
      model: ModelInterface,
      x: np.ndarray,
      y: np.ndarray,
      a: np.ndarray,
  ) -> float:
      """
      Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
      Parameters
      ----------
      model: ModelInterface
          A ModelInteface that is subject to explanation.
      x: np.ndarray
          The input to be evaluated on an instance-basis.
      y: np.ndarray
          The output to be evaluated on an instance-basis.
      a: np.ndarray
          The explanation to be evaluated on an instance-basis.
  
      Returns
      -------
      float
          The evaluation results.
      """
      # Randomly select off-class labels.
      np.random.seed(self.seed)
      y_off = np.array(
          [
              np.random.choice(
                  [
                      y_
                      for y_ in list(np.arange(0, self.num_classes))
                      if y_ != y
                  ]
              )
          ]
      )
      # Explain against a random class.
      a_perturbed = self.explain_batch(
          model, np.expand_dims(x, axis=0), y_off
      )
      return self.similarity_func(a.flatten(), a_perturbed.flatten())
  
file_path: Quantus/quantus/metrics/randomisation/random_logit.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  from quantus.functions.similarity_func import ssim
  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.metrics.base import Metric
label_desc: Use image node_id 3 for calling the RandomLogit obj's underlying member method code with example usage: obj.evaluate_instance(model, x, y, a) and returns: self