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 rpn loss from a batch of inputs and pseudo data samples.
  
  Args:
      x (tuple[Tensor]): Features from FPN.
      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.
  Returns:
      dict: A dictionary of rpn loss components
docstr_tok: ["Calculate","rpn","loss","from","a","batch","of","inputs","and","pseudo","data","samples",".","Args",":","x","(","tuple","[","Tensor","]",")",":","Features","from","FPN",".","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",".","Returns",":","dict",":","A","dictionary","of","rpn","loss","components"]
code: def rpn_loss_by_pseudo_instances(
      self, x: Tuple[Tensor], batch_data_samples: SampleList
  ) -> dict:
      """Calculate rpn loss from a batch of inputs and pseudo data samples.
  
      Args:
          x (tuple[Tensor]): Features from FPN.
          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.
      Returns:
          dict: A dictionary of rpn loss components
      """
  
      rpn_data_samples = copy.deepcopy(batch_data_samples)
      rpn_data_samples = filter_gt_instances(
          rpn_data_samples, score_thr=self.semi_train_cfg.rpn_pseudo_thr
      )
      proposal_cfg = self.student.train_cfg.get(
          "rpn_proposal", self.student.test_cfg.rpn
      )
      # set cat_id of gt_labels to 0 in RPN
      for data_sample in rpn_data_samples:
          data_sample.gt_instances.labels = torch.zeros_like(
              data_sample.gt_instances.labels
          )
  
      (
          rpn_losses,
          rpn_results_list,
      ) = self.student.rpn_head.loss_and_predict(
          x, rpn_data_samples, proposal_cfg=proposal_cfg
      )
      for key in rpn_losses.keys():
          if "loss" in key and "rpn" not in key:
              rpn_losses[f"rpn_{key}"] = rpn_losses.pop(key)
      return rpn_losses, rpn_results_list
  
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 4 for calling the SoftTeacher obj's underlying member method code with example usage: obj.rpn_loss_by_pseudo_instances(x, batch_data_samples) and returns: rpn_losses,  rpn_results_list