class_docstr: Implementation of `Grid RoI Head <https://arxiv.org/abs/1811.12030>`_
  
  Args:
      grid_roi_extractor (:obj:`ConfigDict` or dict): Config of
          roi extractor.
      grid_head (:obj:`ConfigDict` or dict): Config of grid head
class_docstr_tok: ["Implementation","of","`","Grid","RoI","Head","<","https",":","\/\/arxiv.org\/abs\/1811.12030",">","`","_","Args",":","grid_roi_extractor","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","roi","extractor",".","grid_head","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","grid","head"]
docstr: Ramdom jitter positive proposals for training.
  
  Args:
      sampling_results (List[obj:SamplingResult]): Assign results of
          all images in a batch after sampling.
      batch_img_metas (list[dict]): List of image information.
      amplitude (float): Amplitude of random offset. Defaults to 0.15.
  
  Returns:
      list[obj:SamplingResult]: SamplingResults after random jittering.
docstr_tok: ["Ramdom","jitter","positive","proposals","for","training",".","Args",":","sampling_results","(","List","[","obj",":","SamplingResult","]",")",":","Assign","results","of","all","images","in","a","batch","after","sampling",".","batch_img_metas","(","list","[","dict","]",")",":","List","of","image","information",".","amplitude","(","float",")",":","Amplitude","of","random","offset",".","Defaults","to","0.15",".","Returns",":","list","[","obj",":","SamplingResult","]",":","SamplingResults","after","random","jittering","."]
code: def _random_jitter(
      self,
      sampling_results: List[SamplingResult],
      batch_img_metas: List[dict],
      amplitude: float = 0.15,
  ) -> List[SamplingResult]:
      """Ramdom jitter positive proposals for training.
  
      Args:
          sampling_results (List[obj:SamplingResult]): Assign results of
              all images in a batch after sampling.
          batch_img_metas (list[dict]): List of image information.
          amplitude (float): Amplitude of random offset. Defaults to 0.15.
  
      Returns:
          list[obj:SamplingResult]: SamplingResults after random jittering.
      """
      for sampling_result, img_meta in zip(
          sampling_results, batch_img_metas
      ):
          bboxes = sampling_result.pos_priors
          random_offsets = bboxes.new_empty(
              bboxes.shape[0], 4
          ).uniform_(-amplitude, amplitude)
          # before jittering
          cxcy = (bboxes[:, 2:4] + bboxes[:, :2]) / 2
          wh = (bboxes[:, 2:4] - bboxes[:, :2]).abs()
          # after jittering
          new_cxcy = cxcy + wh * random_offsets[:, :2]
          new_wh = wh * (1 + random_offsets[:, 2:])
          # xywh to xyxy
          new_x1y1 = new_cxcy - new_wh / 2
          new_x2y2 = new_cxcy + new_wh / 2
          new_bboxes = torch.cat([new_x1y1, new_x2y2], dim=1)
          # clip bboxes
          max_shape = img_meta["img_shape"]
          if max_shape is not None:
              new_bboxes[:, 0::2].clamp_(min=0, max=max_shape[1] - 1)
              new_bboxes[:, 1::2].clamp_(min=0, max=max_shape[0] - 1)
  
          sampling_result.pos_priors = new_bboxes
      return sampling_results
  
file_path: mmdetection/mmdet/models/roi_heads/grid_roi_head.py
imports: from typing import List, Optional, Tuple
  import torch
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList
  from ..task_modules.samplers import SamplingResult
  from ..utils.misc import unpack_gt_instances
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 2 for calling the GridRoIHead obj's underlying member method code with example usage: obj._random_jitter(sampling_results, batch_img_metas, amplitude) and returns: sampling_results