class_docstr: This class generates anchors (or priors) ``on-the-fly`` for the
  `single shot object detector (SSD) <https://arxiv.org/abs/1512.02325>`_.
class_docstr_tok: ["This","class","generates","anchors","(","or","priors",")","``","on-the-fly","``","for","the","`","single","shot","object","detector","(","SSD",")","<","https",":","\/\/arxiv.org\/abs\/1512.02325",">","`","_","."]
code: def __init__(self, opts, *args, **kwargs) -> None:
      output_strides = getattr(
          opts,
          "anchor_generator.ssd.output_strides",
          [32, 64, 128, 256, -1],
      )
      aspect_ratios = getattr(
          opts,
          "anchor_generator.ssd.aspect_ratios",
          [[2, 3]] * len(output_strides),
      )
  
      min_ratio = getattr(
          opts, "anchor_generator.ssd.min_scale_ratio", 0.1
      )
      max_ratio = getattr(
          opts, "anchor_generator.ssd.max_scale_ratio", 1.05
      )
      no_clipping = getattr(
          opts, "anchor_generator.ssd.no_clipping", False
      )
  
      step = getattr(opts, "anchor_generator.ssd.step", [1])
      if isinstance(step, int):
          step = [step] * len(output_strides)
      elif isinstance(step, List) and len(step) <= len(output_strides):
          step = step + [1] * (len(output_strides) - len(step))
      else:
          logger.error(
              "--anchor-generator.ssd.step should be either a list of ints with the same length as "
              "the output strides OR an integer"
          )
  
      super().__init__()
      aspect_ratios = [list(set(ar)) for ar in aspect_ratios]
      output_strides_aspect_ratio = dict()
      for k, v in zip(output_strides, aspect_ratios):
          output_strides_aspect_ratio[k] = v
      self.output_strides_aspect_ratio = output_strides_aspect_ratio
      self.output_strides = output_strides
      self.anchors_dict = dict()
  
      self.num_output_strides = len(output_strides)
      self.num_aspect_ratios = len(aspect_ratios)
  
      scales = np.linspace(
          min_ratio, max_ratio, len(output_strides) + 1
      )
      self.sizes = dict()
      for i, s in enumerate(output_strides):
          self.sizes[s] = {
              "min": scales[i],
              "max": (scales[i] * scales[i + 1]) ** 0.5,
              "step": step[i],
          }
  
      self.clip = not no_clipping
      self.min_scale_ratio = min_ratio
      self.max_scale_ratio = max_ratio
      self.step = step
  
file_path: ml-cvnets/cvnets/anchor_generator/ssd_anchor_generator.py
imports: import argparse
  from itertools import product
  from typing import List, Optional
  import numpy
  import torch
  from torch import Tensor
  from cvnets.anchor_generator import ANCHOR_GEN_REGISTRY, BaseAnchorGenerator
  from utils import logger
label_desc: Use image node_id 1 to create a new SSDAnchorGenerator object from inherited base classes: BaseAnchorGenerator with example: obj = SSDAnchorGenerator(opts)