code: def coco_mask_rcnn_collate_fn(
      batch: List[Mapping[str, Union[Tensor, Mapping[str, Tensor]]]],
      opts: argparse.Namespace,
      *args,
      **kwargs,
  ) -> Mapping[str, Union[List[Tensor], Mapping[str, List[Tensor]]]]:
      """Combines a list of dictionaries into a single dictionary by concatenating matching fields.
  
      For expected keys, see the keys in the output of `__getitem__` function of COCODetectionMaskRCNN class.
  
      Args:
          batch: A list of dictionaries
          opts: Command-line arguments
  
      Returns:
          A dictionary with `samples` and `targets` as keys.
      """
      new_batch = {"samples": {"image": [], "label": []}, "targets": []}
  
      for b_id, batch_ in enumerate(batch):
          new_batch["samples"]["image"].append(
              batch_["samples"]["image"]
          )
          new_batch["samples"]["label"].append(
              batch_["samples"]["label"]
          )
          new_batch["targets"].append(batch_["targets"])
  
      return new_batch
  
file_path: ml-cvnets/data/datasets/detection/coco_mask_rcnn.py
imports: import argparse
  from typing import List, Mapping, Tuple, Union
  import torch
  from torch import Tensor
  from data.collate_fns import COLLATE_FN_REGISTRY
  from data.datasets import DATASET_REGISTRY
  from data.datasets.detection.coco_base import COCODetection
  from data.transforms import image_pil
  from data.transforms.common import Compose
label_desc: Use image node_id 1 for calling a global function with example usage: coco_mask_rcnn_collate_fn(batch, opts) and returns: new_batch