class_docstr: AnchorGenerator by paddle
class_docstr_tok: ["AnchorGenerator","by","paddle"]
code: def gen_base_anchors(self):
      w = self.base_size
      h = self.base_size
      if self.ctr is None:
          x_ctr = 0.5 * (w - 1)
          y_ctr = 0.5 * (h - 1)
      else:
          x_ctr, y_ctr = self.ctr
  
      h_ratios = paddle.sqrt(self.ratios)
      w_ratios = 1 / h_ratios
      if self.scale_major:
          ws = (w * w_ratios[:] * self.scales[:]).reshape([-1])
          hs = (h * h_ratios[:] * self.scales[:]).reshape([-1])
      else:
          ws = (w * self.scales[:] * w_ratios[:]).reshape([-1])
          hs = (h * self.scales[:] * h_ratios[:]).reshape([-1])
  
      base_anchors = paddle.stack(
          [
              x_ctr - 0.5 * (ws - 1),
              y_ctr - 0.5 * (hs - 1),
              x_ctr + 0.5 * (ws - 1),
              y_ctr + 0.5 * (hs - 1),
          ],
          axis=-1,
      )
      base_anchors = paddle.round(base_anchors)
      return base_anchors
  
imports: import math
  import paddle
  import paddle.nn
  import numpy
  from ppdet.core.workspace import register
label_desc: Use image node_id 3 for calling the S2ANetAnchorGenerator obj's underlying member method code with example usage: obj.gen_base_anchors() and returns: base_anchors