class_docstr: Module that generates anchors for a set of feature maps and
  image sizes, inherited from :py:class:`~monai.apps.detection.networks.utils.anchor_utils.AnchorGenerator`
  
  The module support computing anchors at multiple base anchor shapes
  per feature map.
  
  ``feature_map_scales`` should have the same number of elements with the number of feature maps.
  
  base_anchor_shapes can have an arbitrary number of elements.
  For 2D images, each element represents anchor width and height [w,h].
  For 2D images, each element represents anchor width, height, and depth [w,h,d].
  
  AnchorGenerator will output a set of ``len(base_anchor_shapes)`` anchors
  per spatial location for feature map ``i``.
  
  Args:
      feature_map_scales: scale of anchors for each feature map, i.e., each output level of
          the feature pyramid network (FPN). ``len(feature_map_scales)`` is the number of feature maps.
          ``scale[i]*base_anchor_shapes`` represents the anchor shapes for feature map ``i``.
      base_anchor_shapes: a sequence which represents several anchor shapes for one feature map.
          For N-D images, it is a Sequence of N value Sequence.
      indexing: choose from {'xy', 'ij'}, optional
          Cartesian ('xy') or matrix ('ij', default) indexing of output.
          Cartesian ('xy') indexing swaps axis 0 and 1, which is the setting inside torchvision.
          matrix ('ij', default) indexing keeps the original axis not changed.
          See also indexing in https://pytorch.org/docs/stable/generated/torch.meshgrid.html
  
  Example:
      .. code-block:: python
  
          # 2D example inputs for a 2-level feature maps
          feature_map_scales = (1, 2)
          base_anchor_shapes = ((10, 10), (6, 12), (12, 6))
          anchor_generator = AnchorGeneratorWithAnchorShape(feature_map_scales, base_anchor_shapes)
  
          # 3D example inputs for a 2-level feature maps
          feature_map_scales = (1, 2)
          base_anchor_shapes = ((10, 10, 10), (12, 12, 8), (10, 10, 6), (16, 16, 10))
          anchor_generator = AnchorGeneratorWithAnchorShape(feature_map_scales, base_anchor_shapes)
class_docstr_tok: ["Module","that","generates","anchors","for","a","set","of","feature","maps","and","image","sizes",",","inherited","from",":","py",":","class",":","`","~monai.apps.detection.networks.utils.anchor_utils.AnchorGenerator","`","The","module","support","computing","anchors","at","multiple","base","anchor","shapes","per","feature","map",".","``","feature_map_scales","``","should","have","the","same","number","of","elements","with","the","number","of","feature","maps",".","base_anchor_shapes","can","have","an","arbitrary","number","of","elements",".","For","2D","images",",","each","element","represents","anchor","width","and","height","[","w",",","h","]",".","For","2D","images",",","each","element","represents","anchor","width",",","height",",","and","depth","[","w",",","h",",","d","]",".","AnchorGenerator","will","output","a","set","of","``","len","(","base_anchor_shapes",")","``","anchors","per","spatial","location","for","feature","map","``","i","``",".","Args",":","feature_map_scales",":","scale","of","anchors","for","each","feature","map",",","i.e.",",","each","output","level","of","the","feature","pyramid","network","(","FPN",")",".","``","len","(","feature_map_scales",")","``","is","the","number","of","feature","maps",".","``","scale","[","i","]","*","base_anchor_shapes","``","represents","the","anchor","shapes","for","feature","map","``","i","``",".","base_anchor_shapes",":","a","sequence","which","represents","several","anchor","shapes","for","one","feature","map",".","For","N-D","images",",","it","is","a","Sequence","of","N","value","Sequence",".","indexing",":","choose","from","{","'xy","'",",","'ij","'","}",",","optional","Cartesian","(","'xy","'",")","or","matrix","(","'ij","'",",","default",")","indexing","of","output",".","Cartesian","(","'xy","'",")","indexing","swaps","axis","0","and","1",",","which","is","the","setting","inside","torchvision",".","matrix","(","'ij","'",",","default",")","indexing","keeps","the","original","axis","not","changed",".","See","also","indexing","in","https",":","\/\/pytorch.org\/docs\/stable\/generated\/torch.meshgrid.html","Example",":","..","code-block",":",":","python","#","2D","example","inputs","for","a","2-level","feature","maps","feature_map_scales","=","(","1",",","2",")","base_anchor_shapes","=","(","(","10",",","10",")",",","(","6",",","12",")",",","(","12",",","6",")",")","anchor_generator","=","AnchorGeneratorWithAnchorShape","(","feature_map_scales",",","base_anchor_shapes",")","#","3D","example","inputs","for","a","2-level","feature","maps","feature_map_scales","=","(","1",",","2",")","base_anchor_shapes","=","(","(","10",",","10",",","10",")",",","(","12",",","12",",","8",")",",","(","10",",","10",",","6",")",",","(","16",",","16",",","10",")",")","anchor_generator","=","AnchorGeneratorWithAnchorShape","(","feature_map_scales",",","base_anchor_shapes",")"]
code: def __init__(
      self,
      feature_map_scales: Sequence[int]
      | Sequence[float] = (1, 2, 4, 8),
      base_anchor_shapes: Sequence[Sequence[int]]
      | Sequence[Sequence[float]] = (
          (32, 32, 32),
          (48, 20, 20),
          (20, 48, 20),
          (20, 20, 48),
      ),
      indexing: str = "ij",
  ) -> None:
      nn.Module.__init__(self)
  
      spatial_dims = len(base_anchor_shapes[0])
      spatial_dims = look_up_option(spatial_dims, [2, 3])
      self.spatial_dims = spatial_dims
  
      self.indexing = look_up_option(indexing, ["ij", "xy"])
  
      base_anchor_shapes_t = torch.Tensor(base_anchor_shapes)
      self.cell_anchors = [
          self.generate_anchors_using_shape(s * base_anchor_shapes_t)
          for s in feature_map_scales
      ]
  
file_path: MONAI/monai/apps/detection/utils/anchor_utils.py
imports: from __future__ import annotations
  from typing import List, Sequence
  import torch
  from torch import Tensor, nn
  from monai.utils import ensure_tuple
  from monai.utils.misc import issequenceiterable
  from monai.utils.module import look_up_option
label_desc: Use image node_id 1 to create a new AnchorGeneratorWithAnchorShape object from inherited base classes: AnchorGenerator with example: obj = AnchorGeneratorWithAnchorShape(feature_map_scales, base_anchor_shapes, indexing)