code: def test_coco_best(coco_visiondata_train, coco_visiondata_test):
      # Arrange
      check = ClassPerformance(n_to_show=2, show_only="best")
      # Act
      result = check.run(coco_visiondata_train, coco_visiondata_test)
  
      # Assert
      assert_that(result.display, has_length(1))
      figure = t.cast(BaseFigure, result.display[0])
      assert_that(figure, instance_of(BaseFigure))
      assert_that(figure.data[0]["y"][0], close_to(0.23465, 0.01))
      assert_that(
          figure.data[0]["hovertemplate"],
          equal_to(
              "Dataset=Train<br>Metric=Average Precision<br>Class Name=%{x}"
              "<br>sum of Value=%{y}<extra></extra>"
          ),
      )
      assert_that(figure.data[1]["y"][0], close_to(0.233, 0.01))
      assert_that(
          figure.data[1]["hovertemplate"],
          equal_to(
              "Dataset=Train<br>Metric=Average Recall<br>Class Name=%{x}"
              "<br>sum of Value=%{y}<extra></extra>"
          ),
      )
  
      value = result.value
      assert_that(set(value["Class"]), has_length(71))
      assert_that(value, has_length(244))
      assert_that(
          max(value[value["Dataset"] == "Test"]["Value"]), equal_to(1)
      )
      assert_that(
          max(value[value["Dataset"] == "Train"]["Value"]), equal_to(1)
      )
      assert_that(
          min(value[value["Dataset"] == "Test"]["Value"]), equal_to(0)
      )
      assert_that(
          min(value[value["Dataset"] == "Train"]["Value"]), equal_to(0)
      )
      assert_that(
          value[value["Dataset"] == "Train"]["Value"].mean(),
          close_to(0.402, 0.001),
      )
      assert_that(
          value[value["Dataset"] == "Test"]["Value"].mean(),
          close_to(0.405, 0.001),
      )
  
imports: import re
  import typing
  from hamcrest import assert_that, calling, close_to, equal_to, greater_than, has_items, has_length, instance_of, raises
  from plotly.basedatatypes import BaseFigure
  from deepchecks.core.errors import DeepchecksNotSupportedError, DeepchecksValueError
  from deepchecks.vision.checks import ClassPerformance
  from deepchecks.vision.metrics_utils import CustomClassificationScorer
  from deepchecks.vision.metrics_utils.confusion_matrix_counts_metrics import AVAILABLE_EVALUATING_FUNCTIONS
  from tests.base.utils import equal_condition_result
label_desc: Use image node_id 6 for calling a global function with example usage: test_coco_best(coco_visiondata_train, coco_visiondata_test) without return types