code: def test_plot_pi_hbar_values(
      sort, top_k, metric_names, features, exp
  ):
      """Test if the horizontal bar plot displays the correct values for an exact explanation."""
      axes = plot_permutation_importance(
          exp=exp,
          features=features,
          metric_names=metric_names,
          sort=sort,
          top_k=top_k,
      ).ravel()
  
      method = exp.meta["params"]["method"]
  
      for ax, metric in zip(axes, metric_names):
          if method == "exact":
              datavalues = ax.containers[0].datavalues
              expected_datavalues = np.array(
                  [
                      exp.data["feature_importance"][metric][ft]
                      for ft in features
                  ]
              )
          else:
              datavalues = ax.containers[1].datavalues
              segments = (
                  ax.containers[0].get_children()[0].get_segments()
              )
              stdevs = np.array(
                  [(seg[1, 0] - seg[0, 0]) / 2 for seg in segments]
              )
              expected_datavalues = np.array(
                  [
                      exp.data["feature_importance"][metric][ft]["mean"]
                      for ft in features
                  ]
              )
              expected_stdevs = np.array(
                  [
                      exp.data["feature_importance"][metric][ft]["std"]
                      for ft in features
                  ]
              )
  
          feature_names = [
              txt.get_text() for txt in ax.get_yticklabels()
          ]
          expected_feature_names = [
              exp.data["feature_names"][ft] for ft in features
          ]
  
          if sort:
              sorted_idx = np.argsort(expected_datavalues)[::-1][:top_k]
              expected_datavalues = expected_datavalues[sorted_idx]
              expected_feature_names = [
                  expected_feature_names[i] for i in sorted_idx
              ]
  
              if method == "estimate":
                  expected_stdevs = expected_stdevs[sorted_idx]
  
          assert np.allclose(datavalues, expected_datavalues)
          assert feature_names == expected_feature_names
          assert ax.get_title() == exp.data["metric_names"][metric]
  
          if method == "estimate":
              assert np.allclose(stdevs, expected_stdevs)
  
imports: import re
  from copy import deepcopy
  import matplotlib.pyplot
  import numpy
  import pytest
  from pytest_lazyfixture import lazy_fixture
  from sklearn.metrics import accuracy_score, f1_score, max_error
  from alibi.api.defaults import DEFAULT_DATA_PERMUTATION_IMPORTANCE, DEFAULT_META_PERMUTATION_IMPORTANCE
  from alibi.api.interfaces import Explanation
  from alibi.explainers import PermutationImportance, plot_permutation_importance
label_desc: Use image node_id 25 for calling a global function with example usage: test_plot_pi_hbar_values(sort, top_k, metric_names, features, exp) without return types