code: def test_compute_metric(use_sample_weight, dataset):
      """Test if the computation of the metric is correct."""
      y_true = dataset["classification"]["y_true"]
      y_pred = dataset["classification"]["y_pred"]
      sample_weight = dataset["sample_weight"]
  
      weighted_metric = PermutationImportance._compute_metric(
          metric_fn=accuracy_score,
          y=y_true,
          y_hat=y_pred,
          sample_weight=sample_weight if use_sample_weight else None,
      )
  
      expected_weighted_metric = accuracy_score(
          y_true=y_true,
          y_pred=y_pred,
          sample_weight=sample_weight if use_sample_weight else None,
      )
  
      assert np.allclose(expected_weighted_metric, weighted_metric)
  
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 6 for calling a global function with example usage: test_compute_metric(use_sample_weight, dataset) without return types