class_docstr: Generalized R-CNN. Any models that contains the following three components:
  1. Per-image feature extraction (aka backbone)
  2. Region proposal generation
  3. Per-region feature extraction and prediction
class_docstr_tok: ["Generalized","R-CNN",".","Any","models","that","contains","the","following","three","components",":","1",".","Per-image","feature","extraction","(","aka","backbone",")","2",".","Region","proposal","generation","3",".","Per-region","feature","extraction","and","prediction"]
docstr: Args:
      batched_inputs: a list, batched outputs of :class:`DatasetMapper` .
          Each item in the list contains the inputs for one image.
          For now, each item in the list is a dict that contains:
  
          * image: Tensor, image in (C, H, W) format.
          * instances (optional): groundtruth :class:`Instances`
          * proposals (optional): :class:`Instances`, precomputed proposals.
  
          Other information that's included in the original dicts, such as:
  
          * "height", "width" (int): the output resolution of the model, used in inference.
            See :meth:`postprocess` for details.
  
  Returns:
      list[dict]:
          Each dict is the output for one input image.
          The dict contains one key "instances" whose value is a :class:`Instances`.
          The :class:`Instances` object has the following keys:
          "pred_boxes", "pred_classes", "scores", "pred_masks", "pred_keypoints"
docstr_tok: ["Args",":","batched_inputs",":","a","list",",","batched","outputs","of",":","class",":","`","DatasetMapper","`",".","Each","item","in","the","list","contains","the","inputs","for","one","image",".","For","now",",","each","item","in","the","list","is","a","dict","that","contains",":","*","image",":","Tensor",",","image","in","(","C",",","H",",","W",")","format",".","*","instances","(","optional",")",":","groundtruth",":","class",":","`","Instances","`","*","proposals","(","optional",")",":",":","class",":","`","Instances","`",",","precomputed","proposals",".","Other","information","that","'s","included","in","the","original","dicts",",","such","as",":","*","``","height","''",",","``","width","''","(","int",")",":","the","output","resolution","of","the","model",",","used","in","inference",".","See",":","meth",":","`","postprocess","`","for","details",".","Returns",":","list","[","dict","]",":","Each","dict","is","the","output","for","one","input","image",".","The","dict","contains","one","key","``","instances","''","whose","value","is","a",":","class",":","`","Instances","`",".","The",":","class",":","`","Instances","`","object","has","the","following","keys",":","``","pred_boxes","''",",","``","pred_classes","''",",","``","scores","''",",","``","pred_masks","''",",","``","pred_keypoints","''"]
code: def forward(self, batched_inputs: List[Dict[str, torch.Tensor]]):
      """
      Args:
          batched_inputs: a list, batched outputs of :class:`DatasetMapper` .
              Each item in the list contains the inputs for one image.
              For now, each item in the list is a dict that contains:
  
              * image: Tensor, image in (C, H, W) format.
              * instances (optional): groundtruth :class:`Instances`
              * proposals (optional): :class:`Instances`, precomputed proposals.
  
              Other information that's included in the original dicts, such as:
  
              * "height", "width" (int): the output resolution of the model, used in inference.
                See :meth:`postprocess` for details.
  
      Returns:
          list[dict]:
              Each dict is the output for one input image.
              The dict contains one key "instances" whose value is a :class:`Instances`.
              The :class:`Instances` object has the following keys:
              "pred_boxes", "pred_classes", "scores", "pred_masks", "pred_keypoints"
      """
      if not self.training:
          return self.inference(batched_inputs)
  
      images = self.preprocess_image(batched_inputs)
      if "instances" in batched_inputs[0]:
          gt_instances = [
              x["instances"].to(self.device) for x in batched_inputs
          ]
      else:
          gt_instances = None
  
      features = self.backbone(images.tensor)
  
      if self.proposal_generator is not None:
          proposals, proposal_losses = self.proposal_generator(
              images, features, gt_instances
          )
      else:
          assert "proposals" in batched_inputs[0]
          proposals = [
              x["proposals"].to(self.device) for x in batched_inputs
          ]
          proposal_losses = {}
  
      _, detector_losses = self.roi_heads(
          images, features, proposals, gt_instances
      )
      if self.vis_period > 0:
          storage = get_event_storage()
          if storage.iter % self.vis_period == 0:
              self.visualize_training(batched_inputs, proposals)
  
      losses = {}
      losses.update(detector_losses)
      losses.update(proposal_losses)
      return losses
  
imports: import logging
  import numpy
  from typing import Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from detectron2.config import configurable
  from detectron2.data.detection_utils import convert_image_to_rgb
  from detectron2.layers import move_device_like
  from detectron2.structures import ImageList, Instances
  from detectron2.utils.events import get_event_storage
  from detectron2.utils.logger import log_first_n
  from ..backbone import Backbone, build_backbone
  from ..postprocessing import detector_postprocess
  from ..proposal_generator import build_proposal_generator
  from ..roi_heads import build_roi_heads
  from .build import META_ARCH_REGISTRY
label_desc: Use image node_id 6 for calling the GeneralizedRCNN obj's underlying member method code with example usage: obj.forward(batched_inputs) and returns: losses, self