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], Optional): 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], Optional): 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, Optional): The base scale of octave.
      scales_per_octave (int, Optional): 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]], Optional): 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.
      use_box_type (bool): Whether to warp anchors with the box type data
          structure. Defaults to False.
  
  Examples:
      >>> from mmdet.models.task_modules.
      ... prior_generators import AnchorGenerator
      >>> self = AnchorGenerator([16], [1.], [1.], [9])
      >>> all_anchors = self.grid_priors([(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_priors([(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.]])]
class_docstr_tok: ["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","]",",","Optional",")",":","Anchor","scales","for","anchors","in","a","single","level",".","It","can","not","be","set","at","the","same","time","if","`","octave_base_scale","`","and","`","scales_per_octave","`","are","set",".","base_sizes","(","list","[","int","]",",","Optional",")",":","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",",","Optional",")",":","The","base","scale","of","octave",".","scales_per_octave","(","int",",","Optional",")",":","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","]","]",",","Optional",")",":","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",".","use_box_type","(","bool",")",":","Whether","to","warp","anchors","with","the","box","type","data","structure",".","Defaults","to","False",".","Examples",":",">",">",">","from","mmdet.models.task_modules",".","...","prior_generators","import","AnchorGenerator",">",">",">","self","=","AnchorGenerator","(","[","16","]",",","[","1",".","]",",","[","1",".","]",",","[","9","]",")",">",">",">","all_anchors","=","self.grid_priors","(","[","(","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_priors","(","[","(","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: list[int]: total number of base anchors in a feature grid
code: def num_base_anchors(self) -> List[int]:
      """list[int]: total number of base anchors in a feature grid"""
      return self.num_base_priors
  
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  from mmengine.utils import is_tuple_of
  from torch import Tensor
  from torch.nn.modules.utils import _pair
  from mmdet.registry import TASK_UTILS
  from mmdet.structures.bbox import HorizontalBoxes
label_desc: Use image node_id 2 for calling the AnchorGenerator obj's underlying member method code with example usage: obj.num_base_anchors() and returns: self