class_docstr: 对YOLO的输出进行处理
class_docstr_tok: ["\u5bf9YOLO\u7684\u8f93\u51fa\u8fdb\u884c\u5904\u7406"]
docstr: 更新grids信息并生成新的grids参数
  :param ng: 特征图大小
  :param device:
  :return:
docstr_tok: ["\u66f4\u65b0grids\u4fe1\u606f\u5e76\u751f\u6210\u65b0\u7684grids\u53c2\u6570",":","param","ng",":","\u7279\u5f81\u56fe\u5927\u5c0f",":","param","device",":",":","return",":"]
code: def create_grids(self, ng=(13, 13), device="cpu"):
      """
      更新grids信息并生成新的grids参数
      :param ng: 特征图大小
      :param device:
      :return:
      """
      self.nx, self.ny = ng
      self.ng = torch.tensor(ng, dtype=torch.float)
  
      # build xy offsets 构建每个cell处的anchor的xy偏移量(在feature map上的)
      if not self.training:  # 训练模式不需要回归到最终预测boxes
          yv, xv = torch.meshgrid(
              [
                  torch.arange(self.ny, device=device),
                  torch.arange(self.nx, device=device),
              ]
          )
          # batch_size, na, grid_h, grid_w, wh
          self.grid = (
              torch.stack((xv, yv), 2)
              .view((1, 1, self.ny, self.nx, 2))
              .float()
          )
  
      if self.anchor_vec.device != device:
          self.anchor_vec = self.anchor_vec.to(device)
          self.anchor_wh = self.anchor_wh.to(device)
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/yolov3_spp/models.py
imports: from build_utils.layers import *
  from build_utils.parse_config import *
label_desc: Use image node_id 2 for calling the YOLOLayer obj's underlying member method code with example usage: obj.create_grids(ng, device) without return types