class_docstr: This class encodes and decodes a set of bounding boxes into
  the representation used for training the regressors.
class_docstr_tok: ["This","class","encodes","and","decodes","a","set","of","bounding","boxes","into","the","representation","used","for","training","the","regressors","."]
docstr: 结合anchors和与之对应的gt计算regression参数
  Args:
      reference_boxes: List[Tensor] 每个proposal/anchor对应的gt_boxes
      proposals: List[Tensor] anchors/proposals
  
  Returns: regression parameters
docstr_tok: ["\u7ed3\u5408anchors\u548c\u4e0e\u4e4b\u5bf9\u5e94\u7684gt\u8ba1\u7b97regression\u53c2\u6570","Args",":","reference_boxes",":","List","[","Tensor","]","\u6bcf\u4e2aproposal\/anchor\u5bf9\u5e94\u7684gt_boxes","proposals",":","List","[","Tensor","]","anchors\/proposals","Returns",":","regression","parameters"]
code: def encode(self, reference_boxes, proposals):
      # type: (List[Tensor], List[Tensor]) -> List[Tensor]
      """
      结合anchors和与之对应的gt计算regression参数
      Args:
          reference_boxes: List[Tensor] 每个proposal/anchor对应的gt_boxes
          proposals: List[Tensor] anchors/proposals
  
      Returns: regression parameters
  
      """
      # 统计每张图像的anchors个数，方便后面拼接在一起处理后在分开
      # reference_boxes和proposal数据结构相同
      boxes_per_image = [len(b) for b in reference_boxes]
      reference_boxes = torch.cat(reference_boxes, dim=0)
      proposals = torch.cat(proposals, dim=0)
  
      # targets_dx, targets_dy, targets_dw, targets_dh
      targets = self.encode_single(reference_boxes, proposals)
      return targets.split(boxes_per_image, 0)
  
imports: import torch
  import math
  from typing import List, Tuple
  from torch import Tensor
label_desc: Use image node_id 2 for calling the BoxCoder obj's underlying member method code with example usage: obj.encode(reference_boxes, proposals) and returns: targets