class_docstr: Implementation of Sparseness metric by Chalasani et al., 2020.
  
  Sparseness is quantified using the Gini Index applied to the vector of the absolute values of attributions. The
  test asks that features that are truly predictive of the output F(x) should have significant contributions, and
  similarly, that irrelevant (or weakly-relevant) features should have negligible contributions.
  
  Assumptions:
      - Based on the implementation of the authors as found on the following link:
      <https://github.com/jfc43/advex/blob/master/DNN-Experiments/Fashion-MNIST/utils.py>.
  
  References:
      1) Prasad Chalasani et al.: "Concise explanations of neural networks using adversarial training."
      International Conference on Machine Learning. PMLR, 2020.
  
  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
  ----------
  x: np.ndarray
      The input 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(x: np.ndarray, a: np.ndarray) -> float:
      """
      Evaluate instance gets model and data for a single instance as input and returns the evaluation result.
  
      Parameters
      ----------
      x: np.ndarray
          The input to be evaluated on an instance-basis.
      a: np.ndarray
          The explanation to be evaluated on an instance-basis.
  
      Returns
      -------
      float
          The evaluation results.
      """
      if len(x.shape) == 1:
          newshape = np.prod(x.shape)
      else:
          newshape = np.prod(x.shape[1:])
  
      a = np.array(np.reshape(a, newshape), dtype=np.float64)
      a += 0.0000001
      a = np.sort(a)
      score = (
          np.sum(
              (2 * np.arange(1, a.shape[0] + 1) - a.shape[0] - 1) * a
          )
      ) / (a.shape[0] * np.sum(a))
      return score
  
file_path: Quantus/quantus/metrics/complexity/sparseness.py
imports: import sys
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  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 Sparseness obj's underlying member method code with example usage: obj.evaluate_instance(x, a) and returns: score