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","`"]
docstr: NOTE: this interface is experimental.
  
  Args:
      is_train: whether it's used in training or inference
      augmentations: a list of augmentations or deterministic transforms to apply
      image_format: an image format supported by :func:`detection_utils.read_image`.
      use_instance_mask: whether to process instance segmentation annotations, if available
      use_keypoint: whether to process keypoint annotations if available
      instance_mask_format: one of "polygon" or "bitmask". Process instance segmentation
          masks into this format.
      keypoint_hflip_indices: see :func:`detection_utils.create_keypoint_hflip_indices`
      precomputed_proposal_topk: if given, will load pre-computed
          proposals from dataset_dict and keep the top k proposals for each image.
      recompute_boxes: whether to overwrite bounding box annotations
          by computing tight bounding boxes from instance mask annotations.
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","is_train",":","whether","it","'s","used","in","training","or","inference","augmentations",":","a","list","of","augmentations","or","deterministic","transforms","to","apply","image_format",":","an","image","format","supported","by",":","func",":","`","detection_utils.read_image","`",".","use_instance_mask",":","whether","to","process","instance","segmentation","annotations",",","if","available","use_keypoint",":","whether","to","process","keypoint","annotations","if","available","instance_mask_format",":","one","of","``","polygon","''","or","``","bitmask","''",".","Process","instance","segmentation","masks","into","this","format",".","keypoint_hflip_indices",":","see",":","func",":","`","detection_utils.create_keypoint_hflip_indices","`","precomputed_proposal_topk",":","if","given",",","will","load","pre-computed","proposals","from","dataset_dict","and","keep","the","top","k","proposals","for","each","image",".","recompute_boxes",":","whether","to","overwrite","bounding","box","annotations","by","computing","tight","bounding","boxes","from","instance","mask","annotations","."]
code: def __init__(
      self,
      is_train: bool,
      *,
      augmentations: List[Union[T.Augmentation, T.Transform]],
      image_format: str,
      use_instance_mask: bool = False,
      use_keypoint: bool = False,
      instance_mask_format: str = "polygon",
      keypoint_hflip_indices: Optional[np.ndarray] = None,
      precomputed_proposal_topk: Optional[int] = None,
      recompute_boxes: bool = False,
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          is_train: whether it's used in training or inference
          augmentations: a list of augmentations or deterministic transforms to apply
          image_format: an image format supported by :func:`detection_utils.read_image`.
          use_instance_mask: whether to process instance segmentation annotations, if available
          use_keypoint: whether to process keypoint annotations if available
          instance_mask_format: one of "polygon" or "bitmask". Process instance segmentation
              masks into this format.
          keypoint_hflip_indices: see :func:`detection_utils.create_keypoint_hflip_indices`
          precomputed_proposal_topk: if given, will load pre-computed
              proposals from dataset_dict and keep the top k proposals for each image.
          recompute_boxes: whether to overwrite bounding box annotations
              by computing tight bounding boxes from instance mask annotations.
      """
      if recompute_boxes:
          assert (
              use_instance_mask
          ), "recompute_boxes requires instance masks"
          # fmt: off
          self.is_train               = is_train
          self.augmentations          = augmentations
          self.image_format           = image_format
          self.use_instance_mask      = use_instance_mask
          self.instance_mask_format   = instance_mask_format
          self.use_keypoint           = use_keypoint
          self.keypoint_hflip_indices = keypoint_hflip_indices
          self.proposal_topk          = precomputed_proposal_topk
          self.recompute_boxes        = recompute_boxes
      # fmt: on
      logger = logging.getLogger(__name__)
      logger.info(
          "Augmentations used in training: " + str(augmentations)
      )
  
imports: import itertools
  import random
  import logging
  import operator
  import dill
  import pickle
  from pprint import pformat
  from typing import List, Optional, Union
  import numpy
  import torch
  import torch.utils.data
  from ..structures import BoxMode
  from ...utils.comm import get_world_size
  from ...utils.random import seed_all_rng
  from ..transforms import instance_transforms
  from ..registry.catalog import DatasetCatalog, MetadataCatalog
  from .detection_utils import check_metadata_consistency
  from .None import detection_utils
  from .samplers import InferenceSampler, RepeatFactorTrainingSampler, TrainingSampler
label_desc: Use image node_id 1 to create a new DatasetMapper object  with example: obj = DatasetMapper(is_train)