code: def detection_collate(batch):
      """
      Collate function for detection task. Concatanate bboxes, labels and
      metadata from different samples in the first dimension instead of
      stacking them to have a batch-size dimension.
      Args:
          batch (tuple or list): data batch to collate.
      Returns:
          (tuple): collated detection data batch.
      """
      inputs, labels, video_idx, time, extra_data = zip(*batch)
      inputs, video_idx = default_collate(inputs), default_collate(
          video_idx
      )
      time = default_collate(time)
      labels = torch.tensor(np.concatenate(labels, axis=0)).float()
  
      collated_extra_data = {}
      for key in extra_data[0].keys():
          data = [d[key] for d in extra_data]
          if key == "boxes" or key == "ori_boxes":
              # Append idx info to the bboxes before concatenating them.
              bboxes = [
                  np.concatenate(
                      [
                          np.full((data[i].shape[0], 1), float(i)),
                          data[i],
                      ],
                      axis=1,
                  )
                  for i in range(len(data))
              ]
              bboxes = np.concatenate(bboxes, axis=0)
              collated_extra_data[key] = torch.tensor(bboxes).float()
          elif key == "metadata":
              collated_extra_data[key] = torch.tensor(
                  list(itertools.chain(*data))
              ).view(-1, 2)
          else:
              collated_extra_data[key] = default_collate(data)
  
      return inputs, labels, video_idx, time, collated_extra_data
  
file_path: SlowFast/slowfast/datasets/loader.py
imports: import itertools
  import numpy
  from functools import partial
  from typing import List
  import torch
  from torch.utils.data._utils.collate import default_collate
  from torch.utils.data.distributed import DistributedSampler
  from torch.utils.data.sampler import RandomSampler, Sampler
  from slowfast.datasets.multigrid_helper import ShortCycleBatchSampler
  from .None import utils
  from .build import build_dataset
label_desc: Use image node_id 2 for calling a global function with example usage: detection_collate(batch) and returns: inputs,  labels,  video_idx,  time,  collated_extra_data