code: def generate_anchors_for_grid_cell(
      feats,
      fpn_strides,
      grid_cell_size=5.0,
      grid_cell_offset=0.5,
      dtype="float32",
  ):
      r"""
      Like ATSS, generate anchors based on grid size.
      Args:
          feats (List[Tensor]): shape[s, (b, c, h, w)]
          fpn_strides (tuple|list): shape[s], stride for each scale feature
          grid_cell_size (float): anchor size
          grid_cell_offset (float): The range is between 0 and 1.
      Returns:
          anchors (Tensor): shape[l, 4], "xmin, ymin, xmax, ymax" format.
          anchor_points (Tensor): shape[l, 2], "x, y" format.
          num_anchors_list (List[int]): shape[s], contains [s_1, s_2, ...].
          stride_tensor (Tensor): shape[l, 1], contains the stride for each scale.
      """
      assert len(feats) == len(fpn_strides)
      anchors = []
      anchor_points = []
      num_anchors_list = []
      stride_tensor = []
      for feat, stride in zip(feats, fpn_strides):
          _, _, h, w = feat.shape
          cell_half_size = grid_cell_size * stride * 0.5
          shift_x = (paddle.arange(end=w) + grid_cell_offset) * stride
          shift_y = (paddle.arange(end=h) + grid_cell_offset) * stride
          shift_y, shift_x = paddle.meshgrid(shift_y, shift_x)
          anchor = paddle.stack(
              [
                  shift_x - cell_half_size,
                  shift_y - cell_half_size,
                  shift_x + cell_half_size,
                  shift_y + cell_half_size,
              ],
              axis=-1,
          ).astype(dtype)
          anchor_point = paddle.stack(
              [shift_x, shift_y], axis=-1
          ).astype(dtype)
  
          anchors.append(anchor.reshape([-1, 4]))
          anchor_points.append(anchor_point.reshape([-1, 2]))
          num_anchors_list.append(len(anchors[-1]))
          stride_tensor.append(
              paddle.full(
                  [num_anchors_list[-1], 1], stride, dtype=dtype
              )
          )
      anchors = paddle.concat(anchors)
      anchors.stop_gradient = True
      anchor_points = paddle.concat(anchor_points)
      anchor_points.stop_gradient = True
      stride_tensor = paddle.concat(stride_tensor)
      stride_tensor.stop_gradient = True
      return anchors, anchor_points, num_anchors_list, stride_tensor
  
file_path: PaddleDetection/ppdet/modeling/assigners/utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  import paddle.nn.functional
label_desc: Use image node_id 6 for calling a global function with example usage: generate_anchors_for_grid_cell(feats, fpn_strides, grid_cell_size, grid_cell_offset, dtype) and returns: anchors,  anchor_points,  num_anchors_list,  stride_tensor