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 _generate_anchors(
      self,
      height: int,
      width: int,
      output_stride: int,
      device: Optional[str] = "cpu",
      *args,
      **kwargs,
  ) -> Tensor:
      min_size_h = self.sizes[output_stride]["min"]
      min_size_w = self.sizes[output_stride]["min"]
  
      max_size_h = self.sizes[output_stride]["max"]
      max_size_w = self.sizes[output_stride]["max"]
      aspect_ratio = self.output_strides_aspect_ratio[output_stride]
  
      step = max(1, self.sizes[output_stride]["step"])
  
      default_anchors_ctr = []
  
      start_step = max(0, step // 2)
  
      # Note that feature maps are in NCHW format
      for y, x in product(
          range(start_step, height, step),
          range(start_step, width, step),
      ):
          # [x, y, w, h] format
          cx = (x + 0.5) / width
          cy = (y + 0.5) / height
  
          # small box size
          default_anchors_ctr.append([cx, cy, min_size_w, min_size_h])
  
          # big box size
          default_anchors_ctr.append([cx, cy, max_size_w, max_size_h])
  
          # change h/w ratio of the small sized box based on aspect ratios
          for ratio in aspect_ratio:
              ratio = ratio**0.5
              default_anchors_ctr.extend(
                  [
                      [cx, cy, min_size_w * ratio, min_size_h / ratio],
                      [cx, cy, min_size_w / ratio, min_size_h * ratio],
                  ]
              )
  
      default_anchors_ctr = torch.tensor(
          default_anchors_ctr, dtype=torch.float, device=device
      )
      if self.clip:
          default_anchors_ctr = torch.clamp(
              default_anchors_ctr, min=0.0, max=1.0
          )
  
      return default_anchors_ctr
  
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 5 for calling the SSDAnchorGenerator obj's underlying member method code with example usage: obj._generate_anchors(height, width, output_stride, device) and returns: default_anchors_ctr