class_docstr: A callable which takes a dataset dict in Detectron2 Dataset format,
  and map it into a format used by DETR.
  
  The callable currently does the following:
  
  1. Read the image from "file_name"
  2. Applies geometric transforms to the image and annotation
  3. Find and applies suitable cropping to the image and annotation
  4. Prepare image and annotation to Tensors
class_docstr_tok: ["A","callable","which","takes","a","dataset","dict","in","Detectron2","Dataset","format",",","and","map","it","into","a","format","used","by","DETR",".","The","callable","currently","does","the","following",":","1",".","Read","the","image","from","``","file_name","''","2",".","Applies","geometric","transforms","to","the","image","and","annotation","3",".","Find","and","applies","suitable","cropping","to","the","image","and","annotation","4",".","Prepare","image","and","annotation","to","Tensors"]
docstr: Args:
      dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
  
  Returns:
      dict: a format that builtin models in detectron2 accept
docstr_tok: ["Args",":","dataset_dict","(","dict",")",":","Metadata","of","one","image",",","in","Detectron2","Dataset","format",".","Returns",":","dict",":","a","format","that","builtin","models","in","detectron2","accept"]
code: def __call__(self, dataset_dict):
      """
      Args:
          dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
  
      Returns:
          dict: a format that builtin models in detectron2 accept
      """
      dataset_dict = copy.deepcopy(
          dataset_dict
      )  # it will be modified by code below
      image = utils.read_image(
          dataset_dict["file_name"], format=self.img_format
      )
      utils.check_image_size(dataset_dict, image)
  
      if self.crop_gen is None:
          image, transforms = T.apply_transform_gens(
              self.tfm_gens, image
          )
      else:
          if np.random.rand() > 0.5:
              image, transforms = T.apply_transform_gens(
                  self.tfm_gens, image
              )
          else:
              image, transforms = T.apply_transform_gens(
                  self.tfm_gens[:-1]
                  + self.crop_gen
                  + self.tfm_gens[-1:],
                  image,
              )
  
      image_shape = image.shape[:2]  # h, w
  
      # Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
      # but not efficient on large generic data structures due to the use of pickle & mp.Queue.
      # Therefore it's important to use torch.Tensor.
      dataset_dict["image"] = torch.as_tensor(
          np.ascontiguousarray(image.transpose(2, 0, 1))
      )
  
      if not self.is_train:
          # USER: Modify this if you want to keep them for some reason.
          dataset_dict.pop("annotations", None)
          return dataset_dict
  
      if "annotations" in dataset_dict:
          # USER: Modify this if you want to keep them for some reason.
          for anno in dataset_dict["annotations"]:
              if not self.mask_on:
                  anno.pop("segmentation", None)
              anno.pop("keypoints", None)
  
          # USER: Implement additional transformations if you have other types of data
          annos = [
              utils.transform_instance_annotations(
                  obj, transforms, image_shape
              )
              for obj in dataset_dict.pop("annotations")
              if obj.get("iscrowd", 0) == 0
          ]
          instances = utils.annotations_to_instances(annos, image_shape)
          dataset_dict["instances"] = utils.filter_empty_instances(
              instances
          )
      return dataset_dict
  
file_path: detr/d2/detr/dataset_mapper.py
imports: import copy
  import logging
  import numpy
  import torch
  from detectron2.data import detection_utils
  from detectron2.data import transforms
  from detectron2.data.transforms import TransformGen
label_desc: Use image node_id 2 for calling the DetrDatasetMapper obj's underlying member method code with example usage: obj.__call__(dataset_dict) and returns: dataset_dict, dataset_dict