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.
      approx_anchor_generator (dict): Config dict for approx generator
      square_anchor_generator (dict): Config dict for square generator
      anchor_coder (dict): Config dict for anchor coder
      bbox_coder (dict): Config dict for bbox coder
      deform_groups: (int): Group number of DCN in
          FeatureAdaption module.
      loc_filter_thr (float): Threshold to filter out unconcerned regions.
      loss_loc (dict): Config of location loss.
      loss_shape (dict): Config of anchor shape loss.
      loss_cls (dict): Config of classification loss.
      loss_bbox (dict): Config of bbox regression loss.
docstr: Get sampled approxs and inside flags according to feature map sizes.
  
  Args:
      featmap_sizes (list[tuple]): Multi-level feature map sizes.
      img_metas (list[dict]): Image meta info.
      device (torch.device | str): device for returned tensors
  
  Returns:
      tuple: approxes of each image, inside flags of each image
docstr_tok: ["Get","sampled","approxs","and","inside","flags","according","to","feature","map","sizes",".","Args",":","featmap_sizes","(","list","[","tuple","]",")",":","Multi-level","feature","map","sizes",".","img_metas","(","list","[","dict","]",")",":","Image","meta","info",".","device","(","torch.device","|","str",")",":","device","for","returned","tensors","Returns",":","tuple",":","approxes","of","each","image",",","inside","flags","of","each","image"]
code: def get_sampled_approxs(
      self, featmap_sizes, img_metas, device="cuda"
  ):
      """Get sampled approxs and inside flags according to feature map sizes.
  
      Args:
          featmap_sizes (list[tuple]): Multi-level feature map sizes.
          img_metas (list[dict]): Image meta info.
          device (torch.device | str): device for returned tensors
  
      Returns:
          tuple: approxes of each image, inside flags of each image
      """
      num_imgs = len(img_metas)
  
      # since feature map sizes of all images are the same, we only compute
      # approxes for one time
      multi_level_approxs = self.approx_anchor_generator.grid_anchors(
          featmap_sizes, device=device
      )
      approxs_list = [multi_level_approxs for _ in range(num_imgs)]
  
      # for each image, we compute inside flags of multi level approxes
      inside_flag_list = []
      for img_id, img_meta in enumerate(img_metas):
          multi_level_flags = []
          multi_level_approxs = approxs_list[img_id]
  
          # obtain valid flags for each approx first
          multi_level_approx_flags = (
              self.approx_anchor_generator.valid_flags(
                  featmap_sizes, img_meta["pad_shape"], device=device
              )
          )
  
          for i, flags in enumerate(multi_level_approx_flags):
              approxs = multi_level_approxs[i]
              inside_flags_list = []
              for i in range(self.approxs_per_octave):
                  split_valid_flags = flags[
                      i :: self.approxs_per_octave
                  ]
                  split_approxs = approxs[
                      i :: self.approxs_per_octave, :
                  ]
                  inside_flags = anchor_inside_flags(
                      split_approxs,
                      split_valid_flags,
                      img_meta["img_shape"][:2],
                      self.train_cfg.allowed_border,
                  )
                  inside_flags_list.append(inside_flags)
              # inside_flag for a position is true if any anchor in this
              # position is true
              inside_flags = (
                  torch.stack(inside_flags_list, 0).sum(dim=0) > 0
              )
              multi_level_flags.append(inside_flags)
          inside_flag_list.append(multi_level_flags)
      return approxs_list, inside_flag_list
  
imports: import torch
  import torch.nn
  from mmcv.cnn import bias_init_with_prob, normal_init
  from mmcv.ops import DeformConv2d, MaskedConv2d
  from mmcv.runner import force_fp32
  from mmdet.core import anchor_inside_flags, build_anchor_generator, build_assigner, build_bbox_coder, build_sampler, calc_region, images_to_levels, multi_apply, multiclass_nms, unmap
  from ..builder import HEADS, build_loss
  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_sampled_approxs(featmap_sizes, img_metas, device) and returns: approxs_list,  inside_flag_list