class_docstr: Standard anchor generator for 2D anchor-based detectors.
  
  Args:
      strides (list[int] | list[tuple[int, int]]): Strides of anchors
          in multiple feature levels in order (w, h).
      ratios (list[float]): The list of ratios between the height and width
          of anchors in a single level.
      scales (list[int] | None): Anchor scales for anchors in a single level.
          It cannot be set at the same time if `octave_base_scale` and
          `scales_per_octave` are set.
      base_sizes (list[int] | None): The basic sizes
          of anchors in multiple levels.
          If None is given, strides will be used as base_sizes.
          (If strides are non square, the shortest stride is taken.)
      scale_major (bool): Whether to multiply scales first when generating
          base anchors. If true, the anchors in the same row will have the
          same scales. By default it is True in V2.0
      octave_base_scale (int): The base scale of octave.
      scales_per_octave (int): Number of scales for each octave.
          `octave_base_scale` and `scales_per_octave` are usually used in
          retinanet and the `scales` should be None when they are set.
      centers (list[tuple[float, float]] | None): The centers of the anchor
          relative to the feature grid center in multiple feature levels.
          By default it is set to be None and not used. If a list of tuple of
          float is given, they will be used to shift the centers of anchors.
      center_offset (float): The offset of center in proportion to anchors'
          width and height. By default it is 0 in V2.0.
  
  Examples:
      >>> from mmdet.core import AnchorGenerator
      >>> self = AnchorGenerator([16], [1.], [1.], [9])
      >>> all_anchors = self.grid_anchors([(2, 2)], device='cpu')
      >>> print(all_anchors)
      [tensor([[-4.5000, -4.5000,  4.5000,  4.5000],
              [11.5000, -4.5000, 20.5000,  4.5000],
              [-4.5000, 11.5000,  4.5000, 20.5000],
              [11.5000, 11.5000, 20.5000, 20.5000]])]
      >>> self = AnchorGenerator([16, 32], [1.], [1.], [9, 18])
      >>> all_anchors = self.grid_anchors([(2, 2), (1, 1)], device='cpu')
      >>> print(all_anchors)
      [tensor([[-4.5000, -4.5000,  4.5000,  4.5000],
              [11.5000, -4.5000, 20.5000,  4.5000],
              [-4.5000, 11.5000,  4.5000, 20.5000],
              [11.5000, 11.5000, 20.5000, 20.5000]]),         tensor([[-9., -9., 9., 9.]])]
docstr: Generate the valid flags of anchor in a single feature map.
  
  Args:
      featmap_size (tuple[int]): The size of feature maps.
      valid_size (tuple[int]): The valid size of the feature maps.
      num_base_anchors (int): The number of base anchors.
      device (str, optional): Device where the flags will be put on.
          Defaults to 'cuda'.
  
  Returns:
      torch.Tensor: The valid flags of each anchor in a single level                 feature map.
code: def single_level_valid_flags(
      self, featmap_size, valid_size, num_base_anchors, device="cuda"
  ):
      """Generate the valid flags of anchor in a single feature map.
  
          Args:
              featmap_size (tuple[int]): The size of feature maps.
              valid_size (tuple[int]): The valid size of the feature maps.
              num_base_anchors (int): The number of base anchors.
              device (str, optional): Device where the flags will be put on.
                  Defaults to 'cuda'.
  
          Returns:
              torch.Tensor: The valid flags of each anchor in a single level \
                  feature map.
          """
      feat_h, feat_w = featmap_size
      valid_h, valid_w = valid_size
      assert valid_h <= feat_h and valid_w <= feat_w
      valid_x = torch.zeros(feat_w, dtype=torch.bool, device=device)
      valid_y = torch.zeros(feat_h, dtype=torch.bool, device=device)
      valid_x[:valid_w] = 1
      valid_y[:valid_h] = 1
      valid_xx, valid_yy = self._meshgrid(valid_x, valid_y)
      valid = valid_xx & valid_yy
      valid = (
          valid[:, None]
          .expand(valid.size(0), num_base_anchors)
          .contiguous()
          .view(-1)
      )
      return valid
  
imports: import mmcv
  import numpy
  import torch
  from torch.nn.modules.utils import _pair
  from .builder import ANCHOR_GENERATORS
label_desc: Use image node_id 10 for calling the AnchorGenerator obj's underlying member method code with example usage: obj.single_level_valid_flags(featmap_size, valid_size, num_base_anchors, device) and returns: valid