class_docstr: Implementation of the Relevance Mass Accuracy by Arras et al., 2021.
  
  The Relevance Mass Accuracy computes the ratio of attributions inside the bounding box to
  the sum of overall positive attributions. High scores are desired, as the pixels with the highest positively
  attributed scores should be within the bounding box of the targeted object.
  
  References:
      1) Leila Arras et al.: "CLEVR-XAI: A benchmark dataset for the ground
      truth evaluation of neural network explanations." Inf. Fusion 81 (2022): 14-40.
  
  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","Relevance","Mass","Accuracy","by","Arras","et","al.",",","2021",".","The","Relevance","Mass","Accuracy","computes","the","ratio","of","attributions","inside","the","bounding","box","to","the","sum","of","overall","positive","attributions",".","High","scores","are","desired",",","as","the","pixels","with","the","highest","positively","attributed","scores","should","be","within","the","bounding","box","of","the","targeted","object",".","References",":","1",")","Leila","Arras","et","al",".",":","``","CLEVR-XAI",":","A","benchmark","dataset","for","the","ground","truth","evaluation","of","neural","network","explanations",".","''","Inf",".","Fusion","81","(","2022",")",":","14-40",".","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.
  s: np.ndarray
      The segmentation 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","--","--","--","--","--","a",":","np.ndarray","The","explanation","to","be","evaluated","on","an","instance-basis",".","s",":","np.ndarray","The","segmentation","to","be","evaluated","on","an","instance-basis",".","Returns","--","--","--","-","float","The","evaluation","results","."]
code: def evaluate_instance(
      a: np.ndarray,
      s: 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.
      s: np.ndarray
          The segmentation to be evaluated on an instance-basis.
  
      Returns
      -------
      float
          The evaluation results.
      """
      # Return np.nan as result if segmentation map is empty.
      if np.sum(s) == 0:
          warn.warn_empty_segmentation()
          return np.nan
  
      # Prepare shapes.
      a = a.flatten()
      s = s.flatten().astype(bool)
  
      # Compute inside/outside ratio.
      r_within = np.sum(a[s])
      r_total = np.sum(a)
  
      # Calculate mass accuracy.
      mass_accuracy = r_within / r_total
  
      return mass_accuracy
  
file_path: Quantus/quantus/metrics/localisation/relevance_mass_accuracy.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  from quantus.helpers import asserts, 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 RelevanceMassAccuracy obj's underlying member method code with example usage: obj.evaluate_instance(a, s) and returns: mass_accuracy, np