class_docstr: Anchor-based head (RPN, RetinaNet, SSD, etc.).
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      feat_channels (int): Number of hidden channels. Used in child classes.
      anchor_generator (dict): Config dict for anchor generator
      bbox_coder (dict): Config of bounding box coder.
      reg_decoded_bbox (bool): If true, the regression loss would be
          applied directly on decoded bounding boxes, converting both
          the predicted boxes and regression targets to absolute
          coordinates format. Default False. It should be `True` when
          using `IoULoss`, `GIoULoss`, or `DIoULoss` in the bbox head.
      loss_cls (dict): Config of classification loss.
      loss_bbox (dict): Config of localization loss.
      train_cfg (dict): Training config of anchor head.
      test_cfg (dict): Testing config of anchor head.
      init_cfg (dict or list[dict], optional): Initialization config dict.
class_docstr_tok: ["Anchor-based","head","(","RPN",",","RetinaNet",",","SSD",",","etc.",")",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","feat_channels","(","int",")",":","Number","of","hidden","channels",".","Used","in","child","classes",".","anchor_generator","(","dict",")",":","Config","dict","for","anchor","generator","bbox_coder","(","dict",")",":","Config","of","bounding","box","coder",".","reg_decoded_bbox","(","bool",")",":","If","true",",","the","regression","loss","would","be","applied","directly","on","decoded","bounding","boxes",",","converting","both","the","predicted","boxes","and","regression","targets","to","absolute","coordinates","format",".","Default","False",".","It","should","be","`","True","`","when","using","`","IoULoss","`",",","`","GIoULoss","`",",","or","`","DIoULoss","`","in","the","bbox","head",".","loss_cls","(","dict",")",":","Config","of","classification","loss",".","loss_bbox","(","dict",")",":","Config","of","localization","loss",".","train_cfg","(","dict",")",":","Training","config","of","anchor","head",".","test_cfg","(","dict",")",":","Testing","config","of","anchor","head",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict","."]
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 | 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","|","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 | 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
      )
      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: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import BaseBoxes, cat_boxes, get_box_tensor
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptInstanceList, OptMultiConfig
  from ..task_modules.prior_generators import AnchorGenerator, anchor_inside_flags
  from ..task_modules.samplers import PseudoSampler
  from ..utils import images_to_levels, multi_apply, unmap
  from .base_dense_head import BaseDenseHead
label_desc: Use image node_id 7 for calling the AnchorHead 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