code: def filter_classes_for_display(
      metrics_df: pd.DataFrame,
      metric_to_show_by: str,
      n_to_show: int,
      show_only: str,
      column_to_filter_by: str = "Dataset",
      column_filter_value: str = None,
  ) -> list:
      """Filter the metrics dataframe for display purposes.
  
      Parameters
      ----------
      metrics_df : pd.DataFrame
          Dataframe containing the metrics.
      n_to_show : int
          Number of classes to show in the report.
      show_only : str
          Specify which classes to show in the report. Can be one of the following:
          - 'largest': Show the largest classes.
          - 'smallest': Show the smallest classes.
          - 'random': Show random classes.
          - 'best': Show the classes with the highest score.
          - 'worst': Show the classes with the lowest score.
      metric_to_show_by : str
          Specify the metric to sort the results by. Relevant only when show_only is 'best' or 'worst'.
      column_to_filter_by : str , default: 'Dataset'
          Specify the name of the column to filter by.
      column_filter_value : str , default: None
          Specify the value of the column to filter by, if None will be set to test dataset name.
  
      Returns
      -------
      list
          List of classes to show in the report.
      """
      # working on the test dataset on default
      if column_filter_value is None:
          column_filter_value = DatasetKind.TEST.value
  
      tests_metrics_df = metrics_df[
          (metrics_df[column_to_filter_by] == column_filter_value)
          & (metrics_df["Metric"] == metric_to_show_by)
      ]
      if show_only == "largest":
          tests_metrics_df = tests_metrics_df.sort_values(
              by=["Number of samples", "Value", "Class"],
              ascending=False,
          )
      elif show_only == "smallest":
          tests_metrics_df = tests_metrics_df.sort_values(
              by=["Number of samples", "Value", "Class"], ascending=True
          )
      elif show_only == "random":
          tests_metrics_df = tests_metrics_df.sample(frac=1)
      elif show_only == "best":
          tests_metrics_df = tests_metrics_df.sort_values(
              by=["Value", "Number of samples"], ascending=False
          )
      elif show_only == "worst":
          tests_metrics_df = tests_metrics_df.sort_values(
              by=["Value", "Number of samples"], ascending=True
          )
      else:
          raise ValueError(f"Unknown show_only value: {show_only}")
  
      return tests_metrics_df.head(n_to_show)["Class"].to_list()
  
file_path: deepchecks/deepchecks/vision/metrics_utils/scorers.py
imports: import typing
  from copy import copy
  from numbers import Number
  import numpy
  import pandas
  import torch
  from ignite.metrics import Metric
  from deepchecks.core import DatasetKind
  from deepchecks.core.errors import DeepchecksNotSupportedError, DeepchecksValueError
  from deepchecks.utils.metrics import get_scorer_name
  from deepchecks.vision.metrics_utils import CustomClassificationScorer, CustomMetric, ObjectDetectionAveragePrecision, ObjectDetectionTpFpFn
  from deepchecks.vision.metrics_utils.semantic_segmentation_metrics import MeanDice, MeanIoU
  from deepchecks.vision.vision_data import TaskType, VisionData
label_desc: Use image node_id 6 for calling a global function with example usage: filter_classes_for_display(metrics_df, metric_to_show_by, n_to_show, show_only, column_to_filter_by, column_filter_value) and returns: tests_metrics_df