code: def deepchecks_collate_fn_generator(model, device):
      """Generates a collate function that converts the batch to the deepchecks format, using the given model."""
  
      detr_formatter = COCODETRData()
  
      def deepchecks_collate_fn(batch):
          """A collate function that converts the batch to the format expected by deepchecks."""
  
          # Reproduce the steps of the default collate function
          batch = list(zip(*batch))
  
          images = detr_formatter.batch_to_images(batch)
          labels = detr_formatter.batch_to_labels(batch)
          predictions = detr_formatter.infer_on_batch(
              batch, model, device
          )
  
          return BatchOutputFormat(
              images=images, labels=labels, predictions=predictions
          )
  
      return deepchecks_collate_fn
  
file_path: deepchecks/examples/integrations/hugging_face/deepchecks_hugging_face_tutorial.py
imports: import torch
  from transformers import DetrForObjectDetection
  from typing import Union, List, Iterable
  import numpy
  from deepchecks.vision import VisionData
  import torchvision.transforms
  from deepchecks.vision.datasets.detection import coco_torch
  from deepchecks.vision.datasets.detection import coco_utils
  from deepchecks.vision.vision_data import BatchOutputFormat
  from deepchecks.vision.checks import MeanAveragePrecisionReport
label_desc: Use image node_id 1 for calling a global function with example usage: deepchecks_collate_fn_generator(model, device) and returns: deepchecks_collate_fn, BatchOutputFormat