class_docstr: Implementation of `End-to-End Semi-Supervised Object Detection
  with Soft Teacher <https://arxiv.org/abs/2106.09018>`_
  
  Args:
      detector (:obj:`ConfigDict` or dict): The detector config.
      semi_train_cfg (:obj:`ConfigDict` or dict, optional):
          The semi-supervised training config.
      semi_test_cfg (:obj:`ConfigDict` or dict, optional):
          The semi-supervised testing config.
      data_preprocessor (:obj:`ConfigDict` or dict, optional): Config of
          :class:`DetDataPreprocessor` to process the input data.
          Defaults to None.
      init_cfg (:obj:`ConfigDict` or list[:obj:`ConfigDict`] or dict or
          list[dict], optional): Initialization config dict.
          Defaults to None.
docstr: Calculate losses from a batch of inputs and pseudo data samples.
  
  Args:
      batch_inputs (Tensor): Input images of shape (N, C, H, W).
          These should usually be mean centered and std scaled.
      batch_data_samples (List[:obj:`DetDataSample`]): The batch
          data samples. It usually includes information such
          as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`,
          which are `pseudo_instance` or `pseudo_panoptic_seg`
          or `pseudo_sem_seg` in fact.
      batch_info (dict): Batch information of teacher model
          forward propagation process. Defaults to None.
  
  Returns:
      dict: A dictionary of loss components
docstr_tok: ["Calculate","losses","from","a","batch","of","inputs","and","pseudo","data","samples",".","Args",":","batch_inputs","(","Tensor",")",":","Input","images","of","shape","(","N",",","C",",","H",",","W",")",".","These","should","usually","be","mean","centered","and","std","scaled",".","batch_data_samples","(","List","[",":","obj",":","`","DetDataSample","`","]",")",":","The","batch","data","samples",".","It","usually","includes","information","such","as","`","gt_instance","`","or","`","gt_panoptic_seg","`","or","`","gt_sem_seg","`",",","which","are","`","pseudo_instance","`","or","`","pseudo_panoptic_seg","`","or","`","pseudo_sem_seg","`","in","fact",".","batch_info","(","dict",")",":","Batch","information","of","teacher","model","forward","propagation","process",".","Defaults","to","None",".","Returns",":","dict",":","A","dictionary","of","loss","components"]
code: def loss_by_pseudo_instances(
      self,
      batch_inputs: Tensor,
      batch_data_samples: SampleList,
      batch_info: Optional[dict] = None,
  ) -> dict:
      """Calculate losses from a batch of inputs and pseudo data samples.
  
      Args:
          batch_inputs (Tensor): Input images of shape (N, C, H, W).
              These should usually be mean centered and std scaled.
          batch_data_samples (List[:obj:`DetDataSample`]): The batch
              data samples. It usually includes information such
              as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`,
              which are `pseudo_instance` or `pseudo_panoptic_seg`
              or `pseudo_sem_seg` in fact.
          batch_info (dict): Batch information of teacher model
              forward propagation process. Defaults to None.
  
      Returns:
          dict: A dictionary of loss components
      """
  
      x = self.student.extract_feat(batch_inputs)
  
      losses = {}
      rpn_losses, rpn_results_list = self.rpn_loss_by_pseudo_instances(
          x, batch_data_samples
      )
      losses.update(**rpn_losses)
      losses.update(
          **self.rcnn_cls_loss_by_pseudo_instances(
              x, rpn_results_list, batch_data_samples, batch_info
          )
      )
      losses.update(
          **self.rcnn_reg_loss_by_pseudo_instances(
              x, rpn_results_list, batch_data_samples
          )
      )
      unsup_weight = self.semi_train_cfg.get("unsup_weight", 1.0)
      return rename_loss_dict(
          "unsup_", reweight_loss_dict(losses, unsup_weight)
      )
  
imports: import copy
  from typing import List, Optional, Tuple
  import torch
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models.utils import filter_gt_instances, rename_loss_dict, reweight_loss_dict
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox2roi, bbox_project
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptMultiConfig
  from ..utils.misc import unpack_gt_instances
  from .semi_base import SemiBaseDetector
label_desc: Use image node_id 2 for calling the SoftTeacher obj's underlying member method code with example usage: obj.loss_by_pseudo_instances(batch_inputs, batch_data_samples, batch_info) and returns: rename_loss_dict