class_docstr: Implementation of the permutation feature importance for tabular datasets. The method measure the importance
  of a feature as the relative increase/decrease in the loss/score function when the feature values are permuted.
  Supports black-box models.
  
  For details of the method see the papers:
  
   - https://link.springer.com/article/10.1023/A:1010933404324
  
   - https://arxiv.org/abs/1801.01489
docstr: Helper function to compute the feature importance as the metric ration or the metric difference
  based on the `kind` parameter and the `lower_is_better` flag for multiple metric functions.
  
  Parameters
  ----------
  metric_orig
      A dictionary having as keys the names of the metric functions and as values the metric evaluations when
      the feature values are left intact. The values are lists with a single element.
  metric_permuted
      A dictionary having as keys the names of the metric functions and as values a list of metric evaluations
      when the feature values are permuted.
  kind
      See :py:meth:`alibi.explainers.permutation_importance.PermutationImportance.explain`.
  lower_is_better
      Whether lower metric value is better.
  
  Returns
  -------
  A dictionary having as keys the names of the metric functions and as values the feature importance or
  a dictionary containing the mean and the standard deviation of the feature importance, and the samples used to
  compute the two statistics for the corresponding metrics.
docstr_tok: ["Helper","function","to","compute","the","feature","importance","as","the","metric","ration","or","the","metric","difference","based","on","the","`","kind","`","parameter","and","the","`","lower_is_better","`","flag","for","multiple","metric","functions",".","Parameters","--","--","--","--","--","metric_orig","A","dictionary","having","as","keys","the","names","of","the","metric","functions","and","as","values","the","metric","evaluations","when","the","feature","values","are","left","intact",".","The","values","are","lists","with","a","single","element",".","metric_permuted","A","dictionary","having","as","keys","the","names","of","the","metric","functions","and","as","values","a","list","of","metric","evaluations","when","the","feature","values","are","permuted",".","kind","See",":","py",":","meth",":","`","alibi.explainers.permutation_importance.PermutationImportance.explain","`",".","lower_is_better","Whether","lower","metric","value","is","better",".","Returns","--","--","--","-","A","dictionary","having","as","keys","the","names","of","the","metric","functions","and","as","values","the","feature","importance","or","a","dictionary","containing","the","mean","and","the","standard","deviation","of","the","feature","importance",",","and","the","samples","used","to","compute","the","two","statistics","for","the","corresponding","metrics","."]
code: def _compute_importances(
      metric_orig: Dict[str, List[float]],
      metric_permuted: Dict[str, List[float]],
      kind: str,
      lower_is_better: bool,
  ) -> Dict[str, Any]:
      """
      Helper function to compute the feature importance as the metric ration or the metric difference
      based on the `kind` parameter and the `lower_is_better` flag for multiple metric functions.
  
      Parameters
      ----------
      metric_orig
          A dictionary having as keys the names of the metric functions and as values the metric evaluations when
          the feature values are left intact. The values are lists with a single element.
      metric_permuted
          A dictionary having as keys the names of the metric functions and as values a list of metric evaluations
          when the feature values are permuted.
      kind
          See :py:meth:`alibi.explainers.permutation_importance.PermutationImportance.explain`.
      lower_is_better
          Whether lower metric value is better.
  
      Returns
      -------
      A dictionary having as keys the names of the metric functions and as values the feature importance or
      a dictionary containing the mean and the standard deviation of the feature importance, and the samples used to
      compute the two statistics for the corresponding metrics.
      """
      feature_importance = {}
  
      for metric_name in metric_orig:
          importance_values = [
              PermutationImportance._compute_importance(
                  metric_orig=metric_orig[metric_name][
                      0
                  ],  # a list with just one element
                  metric_permuted=metric_permuted_value,
                  kind=kind,
                  lower_is_better=lower_is_better,
              )
              for metric_permuted_value in metric_permuted[metric_name]
          ]
  
          if len(importance_values) > 1:
              feature_importance[metric_name] = {
                  "mean": np.mean(importance_values),
                  "std": np.std(importance_values),
                  "samples": np.array(importance_values),
              }
          else:
              feature_importance[metric_name] = importance_values[0]  # type: ignore
  
      return feature_importance
  
imports: import copy
  import inspect
  import logging
  import math
  import numbers
  import sys
  from collections import defaultdict
  from copy import deepcopy
  from enum import Enum
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union, no_type_check
  import matplotlib.pyplot
  import numpy
  import sklearn.metrics
  from tqdm import tqdm
  from alibi.api.defaults import DEFAULT_DATA_PERMUTATION_IMPORTANCE, DEFAULT_META_PERMUTATION_IMPORTANCE
  from alibi.api.interfaces import Explainer, Explanation
label_desc: Use image node_id 9 for calling the PermutationImportance obj's underlying member method code with example usage: obj._compute_importances(metric_orig, metric_permuted, kind, lower_is_better) and returns: feature_importance