class_docstr: Detects labels that appear only in the test set.
  
  Parameters
  ----------
  max_images_to_display_per_label : int , default: 3
      maximum number of images to show from each newly found label in the test set.
  max_new_labels_to_display : int , default: 3
      Maximum number of new labels to display in output.
  {additional_check_init_params:2*indent}
class_docstr_tok: ["Detects","labels","that","appear","only","in","the","test","set",".","Parameters","--","--","--","--","--","max_images_to_display_per_label",":","int",",","default",":","3","maximum","number","of","images","to","show","from","each","newly","found","label","in","the","test","set",".","max_new_labels_to_display",":","int",",","default",":","3","Maximum","number","of","new","labels","to","display","in","output",".","{","additional_check_init_params:2","*","indent","}"]
docstr: Calculate which class_id are only available in the test data set and display them.
  
  Returns
  -------
  CheckResult
      value: A dictionary showing new class_ids introduced in the test set and number of times they were spotted.
      display: Images containing said class_ids from the test set.
docstr_tok: ["Calculate","which","class_id","are","only","available","in","the","test","data","set","and","display","them",".","Returns","--","--","--","-","CheckResult","value",":","A","dictionary","showing","new","class_ids","introduced","in","the","test","set","and","number","of","times","they","were","spotted",".","display",":","Images","containing","said","class_ids","from","the","test","set","."]
code: def compute(self, context: Context) -> CheckResult:
      """Calculate which class_id are only available in the test data set and display them.
  
      Returns
      -------
      CheckResult
          value: A dictionary showing new class_ids introduced in the test set and number of times they were spotted.
          display: Images containing said class_ids from the test set.
      """
      test_data = context.get_data_by_kind(DatasetKind.TEST)
      labels_only_in_test = {
          key: value
          for key, value in test_data.get_cache()["labels"].items()
          if key
          not in context.get_data_by_kind(
              DatasetKind.TRAIN
          ).get_cache()["labels"]
      }
  
      # sort by number of appearances in test set in descending order
      labels_only_in_test = dict(
          sorted(labels_only_in_test.items(), key=lambda item: -item[1])
      )
  
      result_value = {
          "new_labels": labels_only_in_test,
          "all_labels_count": sum(
              test_data.get_cache()["labels"].values()
          ),
      }
  
      if context.with_display:
          # Create display
          displays = []
          images_per_class = {
              test_data.label_map[key]: value
              for key, value in self._display_images.items()
          }
          for (
              class_name,
              num_occurrences,
          ) in labels_only_in_test.items():
              # Create id of alphabetic characters
              sid = "".join(
                  [choice(string.ascii_uppercase) for _ in range(3)]
              )
              thumbnail_images = [
                  draw_image(
                      img,
                      labels,
                      test_data.task_type,
                      test_data.label_map,
                  )
                  for img, labels in zip(
                      images_per_class[class_name]["images"],
                      images_per_class[class_name]["labels"],
                  )
              ]
              images_combine = "".join(
                  [
                      f'<div class="{sid}-item">{img}</div>'
                      for img in thumbnail_images
                  ]
              )
  
              html = HTML_TEMPLATE.format(
                  label_name=class_name,
                  images=images_combine,
                  count=format_number(num_occurrences),
                  dataset_name=context.test.name,
                  id=sid,
              )
              displays.append(html)
              if len(displays) == self.max_new_labels_to_display:
                  break
      else:
          displays = None
  
      return CheckResult(result_value, display=displays)
  
imports: import string
  from collections import defaultdict
  from secrets import choice
  from typing import Dict, Optional
  import numpy
  from deepchecks.core import CheckResult, ConditionResult, DatasetKind
  from deepchecks.core.condition import ConditionCategory
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.core.reduce_classes import ReduceLabelMixin
  from deepchecks.utils.strings import format_number, format_percent
  from deepchecks.vision._shared_docs import docstrings
  from deepchecks.vision.base_checks import TrainTestCheck
  from deepchecks.vision.context import Context
  from deepchecks.vision.utils.image_functions import draw_image
  from deepchecks.vision.vision_data import TaskType
  from deepchecks.vision.vision_data.batch_wrapper import BatchWrapper
label_desc: Use image node_id 4 for calling the NewLabels obj's underlying member method code with example usage: obj.compute(context) and returns: CheckResult