class_docstr: Detection Head of RTMDet.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      with_objectness (bool): Whether to add an objectness branch.
          Defaults to True.
      act_cfg (:obj:`ConfigDict` or dict): Config dict for activation layer.
          Default: dict(type='ReLU')
class_docstr_tok: ["Detection","Head","of","RTMDet",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","with_objectness","(","bool",")",":","Whether","to","add","an","objectness","branch",".","Defaults","to","True",".","act_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","activation","layer",".","Default",":","dict","(","type='ReLU","'",")"]
docstr: Get anchors according to feature map sizes.
  
  Args:
      featmap_sizes (list[tuple]): Multi-level feature map sizes.
      batch_img_metas (list[dict]): Image meta info.
      device (torch.device or str): Device for returned tensors.
          Defaults to cuda.
  
  Returns:
      tuple:
  
      - anchor_list (list[list[Tensor]]): Anchors of each image.
      - valid_flag_list (list[list[Tensor]]): Valid flags of each
        image.
docstr_tok: ["Get","anchors","according","to","feature","map","sizes",".","Args",":","featmap_sizes","(","list","[","tuple","]",")",":","Multi-level","feature","map","sizes",".","batch_img_metas","(","list","[","dict","]",")",":","Image","meta","info",".","device","(","torch.device","or","str",")",":","Device","for","returned","tensors",".","Defaults","to","cuda",".","Returns",":","tuple",":","-","anchor_list","(","list","[","list","[","Tensor","]","]",")",":","Anchors","of","each","image",".","-","valid_flag_list","(","list","[","list","[","Tensor","]","]",")",":","Valid","flags","of","each","image","."]
code: def get_anchors(
      self,
      featmap_sizes: List[tuple],
      batch_img_metas: List[dict],
      device: Union[torch.device, str] = "cuda",
  ) -> Tuple[List[List[Tensor]], List[List[Tensor]]]:
      """Get anchors according to feature map sizes.
  
      Args:
          featmap_sizes (list[tuple]): Multi-level feature map sizes.
          batch_img_metas (list[dict]): Image meta info.
          device (torch.device or str): Device for returned tensors.
              Defaults to cuda.
  
      Returns:
          tuple:
  
          - anchor_list (list[list[Tensor]]): Anchors of each image.
          - valid_flag_list (list[list[Tensor]]): Valid flags of each
            image.
      """
      num_imgs = len(batch_img_metas)
  
      # since feature map sizes of all images are the same, we only compute
      # anchors for one time
      multi_level_anchors = self.prior_generator.grid_priors(
          featmap_sizes, device=device, with_stride=True
      )
      anchor_list = [multi_level_anchors for _ in range(num_imgs)]
  
      # for each image, we compute valid flags of multi level anchors
      valid_flag_list = []
      for img_id, img_meta in enumerate(batch_img_metas):
          multi_level_flags = self.prior_generator.valid_flags(
              featmap_sizes, img_meta["pad_shape"], device
          )
          valid_flag_list.append(multi_level_flags)
      return anchor_list, valid_flag_list
  
imports: from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule, Scale, is_norm
  from mmengine.model import bias_init_with_prob, constant_init, normal_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import distance2bbox
  from mmdet.utils import ConfigType, InstanceList, OptInstanceList, reduce_mean
  from ..layers.transformer import inverse_sigmoid
  from ..task_modules import anchor_inside_flags
  from ..utils import images_to_levels, multi_apply, sigmoid_geometric_mean, unmap
  from .atss_head import ATSSHead
label_desc: Use image node_id 9 for calling the RTMDetHead obj's underlying member method code with example usage: obj.get_anchors(featmap_sizes, batch_img_metas, device) and returns: anchor_list,  valid_flag_list