class_docstr: Implementation of `Distilling the Knowledge in a Neural Network.
  <https://arxiv.org/abs/1503.02531>`_.
  
  Args:
      backbone (:obj:`ConfigDict` or dict): The backbone module.
      neck (:obj:`ConfigDict` or dict): The neck module.
      bbox_head (:obj:`ConfigDict` or dict): The bbox head module.
      teacher_config (:obj:`ConfigDict` | dict | str | Path): Config file
          path or the config object of teacher model.
      teacher_ckpt (str, optional): Checkpoint path of teacher model.
          If left as None, the model will not load any weights.
          Defaults to True.
      eval_teacher (bool): Set the train mode for teacher.
          Defaults to True.
      train_cfg (:obj:`ConfigDict` or dict, optional): The training config
          of ATSS. Defaults to None.
      test_cfg (:obj:`ConfigDict` or dict, optional): The testing config
          of ATSS. Defaults to None.
      data_preprocessor (:obj:`ConfigDict` or dict, optional): Config of
          :class:`DetDataPreprocessor` to process the input data.
          Defaults to None.
class_docstr_tok: ["Implementation","of","`","Distilling","the","Knowledge","in","a","Neural","Network",".","<","https",":","\/\/arxiv.org\/abs\/1503.02531",">","`","_",".","Args",":","backbone","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","backbone","module",".","neck","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","neck","module",".","bbox_head","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","bbox","head","module",".","teacher_config","(",":","obj",":","`","ConfigDict","`","|","dict","|","str","|","Path",")",":","Config","file","path","or","the","config","object","of","teacher","model",".","teacher_ckpt","(","str",",","optional",")",":","Checkpoint","path","of","teacher","model",".","If","left","as","None",",","the","model","will","not","load","any","weights",".","Defaults","to","True",".","eval_teacher","(","bool",")",":","Set","the","train","mode","for","teacher",".","Defaults","to","True",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","The","training","config","of","ATSS",".","Defaults","to","None",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","The","testing","config","of","ATSS",".","Defaults","to","None",".","data_preprocessor","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","of",":","class",":","`","DetDataPreprocessor","`","to","process","the","input","data",".","Defaults","to","None","."]
docstr: 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`.
  
  Returns:
      dict[str, Tensor]: A dictionary of loss components.
docstr_tok: ["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","`",".","Returns",":","dict","[","str",",","Tensor","]",":","A","dictionary","of","loss","components","."]
code: def loss(
      self, batch_inputs: Tensor, batch_data_samples: SampleList
  ) -> dict:
      """
      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`.
  
      Returns:
          dict[str, Tensor]: A dictionary of loss components.
      """
      x = self.extract_feat(batch_inputs)
      with torch.no_grad():
          teacher_x = self.teacher_model.extract_feat(batch_inputs)
          out_teacher = self.teacher_model.bbox_head(teacher_x)
      losses = self.bbox_head.loss(x, out_teacher, batch_data_samples)
      return losses
  
file_path: mmdetection/mmdet/models/detectors/kd_one_stage.py
imports: from pathlib import Path
  from typing import Any, Optional, Union
  import torch
  import torch.nn
  from mmengine.config import Config
  from mmengine.runner import load_checkpoint
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType
  from .single_stage import SingleStageDetector
label_desc: Use image node_id 2 for calling the KnowledgeDistillationSingleStageDetector obj's underlying member method code with example usage: obj.loss(batch_inputs, batch_data_samples) and returns: losses