class_docstr: Standard points generator for multi-level (Mlvl) feature maps in 2D
  points-based detectors.
  
  Args:
      strides (list[int] | list[tuple[int, int]]): Strides of anchors
          in multiple feature levels in order (w, h).
      offset (float): The offset of points, the value is normalized with
          corresponding stride. Defaults to 0.5.
docstr: Generate grid Points of a single level.
  
  Note:
      This function is usually called by method ``self.grid_priors``.
  
  Args:
      featmap_size (tuple[int]): Size of the feature maps, arrange as
          (h, w).
      level_idx (int): The index of corresponding feature map level.
      dtype (:obj:`dtype`): Dtype of priors. Default: torch.float32.
      device (str, optional): The device the tensor will be put on.
          Defaults to 'cuda'.
      with_stride (bool): Concatenate the stride to the last dimension
          of points.
  
  Return:
      Tensor: Points of single feature levels.
      The shape of tensor should be (N, 2) when with stride is
      ``False``, where N = width * height, width and height
      are the sizes of the corresponding feature level,
      and the last dimension 2 represent (coord_x, coord_y),
      otherwise the shape should be (N, 4),
      and the last dimension 4 represent
      (coord_x, coord_y, stride_w, stride_h).
docstr_tok: ["Generate","grid","Points","of","a","single","level",".","Note",":","This","function","is","usually","called","by","method","``","self.grid_priors","``",".","Args",":","featmap_size","(","tuple","[","int","]",")",":","Size","of","the","feature","maps",",","arrange","as","(","h",",","w",")",".","level_idx","(","int",")",":","The","index","of","corresponding","feature","map","level",".","dtype","(",":","obj",":","`","dtype","`",")",":","Dtype","of","priors",".","Default",":","torch.float32",".","device","(","str",",","optional",")",":","The","device","the","tensor","will","be","put","on",".","Defaults","to","'cuda","'",".","with_stride","(","bool",")",":","Concatenate","the","stride","to","the","last","dimension","of","points",".","Return",":","Tensor",":","Points","of","single","feature","levels",".","The","shape","of","tensor","should","be","(","N",",","2",")","when","with","stride","is","``","False","``",",","where","N","=","width","*","height",",","width","and","height","are","the","sizes","of","the","corresponding","feature","level",",","and","the","last","dimension","2","represent","(","coord_x",",","coord_y",")",",","otherwise","the","shape","should","be","(","N",",","4",")",",","and","the","last","dimension","4","represent","(","coord_x",",","coord_y",",","stride_w",",","stride_h",")","."]
code: def single_level_grid_priors(
      self,
      featmap_size,
      level_idx,
      dtype=torch.float32,
      device="cuda",
      with_stride=False,
  ):
      """Generate grid Points of a single level.
  
      Note:
          This function is usually called by method ``self.grid_priors``.
  
      Args:
          featmap_size (tuple[int]): Size of the feature maps, arrange as
              (h, w).
          level_idx (int): The index of corresponding feature map level.
          dtype (:obj:`dtype`): Dtype of priors. Default: torch.float32.
          device (str, optional): The device the tensor will be put on.
              Defaults to 'cuda'.
          with_stride (bool): Concatenate the stride to the last dimension
              of points.
  
      Return:
          Tensor: Points of single feature levels.
          The shape of tensor should be (N, 2) when with stride is
          ``False``, where N = width * height, width and height
          are the sizes of the corresponding feature level,
          and the last dimension 2 represent (coord_x, coord_y),
          otherwise the shape should be (N, 4),
          and the last dimension 4 represent
          (coord_x, coord_y, stride_w, stride_h).
      """
      feat_h, feat_w = featmap_size
      stride_w, stride_h = self.strides[level_idx]
      shift_x = (
          torch.arange(0, feat_w, device=device) + self.offset
      ) * stride_w
      # keep featmap_size as Tensor instead of int, so that we
      # can convert to ONNX correctly
      shift_x = shift_x.to(dtype)
  
      shift_y = (
          torch.arange(0, feat_h, device=device) + self.offset
      ) * stride_h
      # keep featmap_size as Tensor instead of int, so that we
      # can convert to ONNX correctly
      shift_y = shift_y.to(dtype)
      shift_xx, shift_yy = self._meshgrid(shift_x, shift_y)
      if not with_stride:
          shifts = torch.stack([shift_xx, shift_yy], dim=-1)
      else:
          # use `shape[0]` instead of `len(shift_xx)` for ONNX export
          stride_w = shift_xx.new_full(
              (shift_xx.shape[0],), stride_w
          ).to(dtype)
          stride_h = shift_xx.new_full(
              (shift_yy.shape[0],), stride_h
          ).to(dtype)
          shifts = torch.stack(
              [shift_xx, shift_yy, stride_w, stride_h], dim=-1
          )
      all_points = shifts.to(device)
      return all_points
  
file_path: dinov2/dinov2/eval/segmentation_m2f/core/anchor/point_generator.py
imports: import numpy
  import torch
  from torch.nn.modules.utils import _pair
  from .builder import PRIOR_GENERATORS
label_desc: Use image node_id 6 for calling the MlvlPointGenerator obj's underlying member method code with example usage: obj.single_level_grid_priors(featmap_size, level_idx, dtype, device, with_stride) and returns: all_points