class_docstr: Guided-Anchor-based head (GA-RPN, GA-RetinaNet, etc.).
  
  This GuidedAnchorHead will predict high-quality feature guided
  anchors and locations where anchors will be kept in inference.
  There are mainly 3 categories of bounding-boxes.
  
  - Sampled 9 pairs for target assignment. (approxes)
  - The square boxes where the predicted anchors are based on. (squares)
  - Guided anchors.
  
  Please refer to https://arxiv.org/abs/1901.03278 for more details.
  
  Args:
      num_classes (int): Number of classes.
      in_channels (int): Number of channels in the input feature map.
      feat_channels (int): Number of hidden channels. Defaults to 256.
      approx_anchor_generator (:obj:`ConfigDict` or dict): Config dict
          for approx generator
      square_anchor_generator (:obj:`ConfigDict` or dict): Config dict
          for square generator
      anchor_coder (:obj:`ConfigDict` or dict): Config dict for anchor coder
      bbox_coder (:obj:`ConfigDict` or dict): Config dict for bbox 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. Defaults to False. It should be `True` when
          using `IoULoss`, `GIoULoss`, or `DIoULoss` in the bbox head.
      deform_groups: (int): Group number of DCN in FeatureAdaption module.
          Defaults to 4.
      loc_filter_thr (float): Threshold to filter out unconcerned regions.
          Defaults to 0.01.
      loss_loc (:obj:`ConfigDict` or dict): Config of location loss.
      loss_shape (:obj:`ConfigDict` or dict): Config of anchor shape loss.
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_bbox (:obj:`ConfigDict` or dict): Config of bbox regression loss.
      init_cfg (:obj:`ConfigDict` or list[:obj:`ConfigDict`] or dict or             list[dict], optional): Initialization config dict.
class_docstr_tok: ["Guided-Anchor-based","head","(","GA-RPN",",","GA-RetinaNet",",","etc.",")",".","This","GuidedAnchorHead","will","predict","high-quality","feature","guided","anchors","and","locations","where","anchors","will","be","kept","in","inference",".","There","are","mainly","3","categories","of","bounding-boxes",".","-","Sampled","9","pairs","for","target","assignment",".","(","approxes",")","-","The","square","boxes","where","the","predicted","anchors","are","based","on",".","(","squares",")","-","Guided","anchors",".","Please","refer","to","https",":","\/\/arxiv.org\/abs\/1901.03278","for","more","details",".","Args",":","num_classes","(","int",")",":","Number","of","classes",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","feat_channels","(","int",")",":","Number","of","hidden","channels",".","Defaults","to","256.","approx_anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","approx","generator","square_anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","square","generator","anchor_coder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","anchor","coder","bbox_coder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","bbox","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",".","Defaults","to","False",".","It","should","be","`","True","`","when","using","`","IoULoss","`",",","`","GIoULoss","`",",","or","`","DIoULoss","`","in","the","bbox","head",".","deform_groups",":","(","int",")",":","Group","number","of","DCN","in","FeatureAdaption","module",".","Defaults","to","4.","loc_filter_thr","(","float",")",":","Threshold","to","filter","out","unconcerned","regions",".","Defaults","to","0.01.","loss_loc","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","location","loss",".","loss_shape","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","anchor","shape","loss",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss",".","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","bbox","regression","loss",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","list","[",":","obj",":","`","ConfigDict","`","]","or","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict","."]
docstr: Get squares according to feature map sizes and guided anchors.
  
  Args:
      featmap_sizes (list[tuple]): Multi-level feature map sizes.
      shape_preds (list[tensor]): Multi-level shape predictions.
      loc_preds (list[tensor]): Multi-level location predictions.
      batch_img_metas (list[dict]): Image meta info.
      use_loc_filter (bool): Use loc filter or not. Defaults to False
      device (str): device for returned tensors.
          Defaults to `cuda`.
  
  Returns:
      tuple: square approxs of each image, guided anchors of each image,
      loc masks of each image.
docstr_tok: ["Get","squares","according","to","feature","map","sizes","and","guided","anchors",".","Args",":","featmap_sizes","(","list","[","tuple","]",")",":","Multi-level","feature","map","sizes",".","shape_preds","(","list","[","tensor","]",")",":","Multi-level","shape","predictions",".","loc_preds","(","list","[","tensor","]",")",":","Multi-level","location","predictions",".","batch_img_metas","(","list","[","dict","]",")",":","Image","meta","info",".","use_loc_filter","(","bool",")",":","Use","loc","filter","or","not",".","Defaults","to","False","device","(","str",")",":","device","for","returned","tensors",".","Defaults","to","`","cuda","`",".","Returns",":","tuple",":","square","approxs","of","each","image",",","guided","anchors","of","each","image",",","loc","masks","of","each","image","."]
code: def get_anchors(
      self,
      featmap_sizes: List[Tuple[int, int]],
      shape_preds: List[Tensor],
      loc_preds: List[Tensor],
      batch_img_metas: List[dict],
      use_loc_filter: bool = False,
      device: str = "cuda",
  ) -> tuple:
      """Get squares according to feature map sizes and guided anchors.
  
      Args:
          featmap_sizes (list[tuple]): Multi-level feature map sizes.
          shape_preds (list[tensor]): Multi-level shape predictions.
          loc_preds (list[tensor]): Multi-level location predictions.
          batch_img_metas (list[dict]): Image meta info.
          use_loc_filter (bool): Use loc filter or not. Defaults to False
          device (str): device for returned tensors.
              Defaults to `cuda`.
  
      Returns:
          tuple: square approxs of each image, guided anchors of each image,
          loc masks of each image.
      """
      num_imgs = len(batch_img_metas)
      num_levels = len(featmap_sizes)
  
      # since feature map sizes of all images are the same, we only compute
      # squares for one time
      multi_level_squares = self.square_anchor_generator.grid_priors(
          featmap_sizes, device=device
      )
      squares_list = [multi_level_squares for _ in range(num_imgs)]
  
      # for each image, we compute multi level guided anchors
      guided_anchors_list = []
      loc_mask_list = []
      for img_id, img_meta in enumerate(batch_img_metas):
          multi_level_guided_anchors = []
          multi_level_loc_mask = []
          for i in range(num_levels):
              squares = squares_list[img_id][i]
              shape_pred = shape_preds[i][img_id]
              loc_pred = loc_preds[i][img_id]
              (
                  guided_anchors,
                  loc_mask,
              ) = self._get_guided_anchors_single(
                  squares,
                  shape_pred,
                  loc_pred,
                  use_loc_filter=use_loc_filter,
              )
              multi_level_guided_anchors.append(guided_anchors)
              multi_level_loc_mask.append(loc_mask)
          guided_anchors_list.append(multi_level_guided_anchors)
          loc_mask_list.append(multi_level_loc_mask)
      return squares_list, guided_anchors_list, loc_mask_list
  
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from mmcv.ops import DeformConv2d, MaskedConv2d
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType, OptInstanceList
  from ..layers import multiclass_nms
  from ..task_modules.prior_generators import anchor_inside_flags, calc_region
  from ..task_modules.samplers import PseudoSampler
  from ..utils import images_to_levels, multi_apply, unmap
  from .anchor_head import AnchorHead
label_desc: Use image node_id 6 for calling the GuidedAnchorHead obj's underlying member method code with example usage: obj.get_anchors(featmap_sizes, shape_preds, loc_preds, batch_img_metas, use_loc_filter, device) and returns: squares_list,  guided_anchors_list,  loc_mask_list