class_docstr: A callable which takes a dataset dict in Detectron2 Dataset format,
  and map it into a format used by the model.
  
  This is the default callable to be used to map your dataset dict into training data.
  You may need to follow it to implement your own one for customized logic,
  such as a different way to read or transform images.
  See :doc:`/tutorials/data_loading` for details.
  
  The callable currently does the following:
  
  1. Read the image from "file_name"
  2. Applies cropping/geometric transforms to the image and annotations
  3. Prepare data and annotations to Tensor and :class:`Instances`
class_docstr_tok: ["A","callable","which","takes","a","dataset","dict","in","Detectron2","Dataset","format",",","and","map","it","into","a","format","used","by","the","model",".","This","is","the","default","callable","to","be","used","to","map","your","dataset","dict","into","training","data",".","You","may","need","to","follow","it","to","implement","your","own","one","for","customized","logic",",","such","as","a","different","way","to","read","or","transform","images",".","See",":","doc",":","`","\/tutorials\/data_loading","`","for","details",".","The","callable","currently","does","the","following",":","1",".","Read","the","image","from","``","file_name","''","2",".","Applies","cropping\/geometric","transforms","to","the","image","and","annotations","3",".","Prepare","data","and","annotations","to","Tensor","and",":","class",":","`","Instances","`"]
code: def from_config(cls, cfg, is_train: bool = True):
      augs = utils.build_augmentation(cfg, is_train)
      if cfg.INPUT.CROP.ENABLED and is_train:
          augs.insert(
              0, T.RandomCrop(cfg.INPUT.CROP.TYPE, cfg.INPUT.CROP.SIZE)
          )
          recompute_boxes = cfg.MODEL.MASK_ON
      else:
          recompute_boxes = False
  
      ret = {
          "is_train": is_train,
          "augmentations": augs,
          "image_format": cfg.INPUT.FORMAT,
          "use_instance_mask": cfg.MODEL.MASK_ON,
          "instance_mask_format": cfg.INPUT.MASK_FORMAT,
          "use_keypoint": cfg.MODEL.KEYPOINT_ON,
          "recompute_boxes": recompute_boxes,
      }
  
      if cfg.MODEL.KEYPOINT_ON:
          ret[
              "keypoint_hflip_indices"
          ] = utils.create_keypoint_hflip_indices(cfg.DATASETS.TRAIN)
  
      if cfg.MODEL.LOAD_PROPOSALS:
          ret["precomputed_proposal_topk"] = (
              cfg.DATASETS.PRECOMPUTED_PROPOSAL_TOPK_TRAIN
              if is_train
              else cfg.DATASETS.PRECOMPUTED_PROPOSAL_TOPK_TEST
          )
      return ret
  
file_path: detectron2/detectron2/data/dataset_mapper.py
imports: import copy
  import logging
  import numpy
  from typing import List, Optional, Union
  import torch
  from detectron2.config import configurable
  from .None import detection_utils
  from .None import transforms
label_desc: Use image node_id 2 for calling the DatasetMapper obj's underlying member method code with example usage: obj.from_config(cls, cfg, is_train) and returns: ret