code: def generate_anchors(input_size, grid_sizes, scales, aspect_ratios):
      assert len(scales) == len(aspect_ratios) == len(grid_sizes)
      anchors = []
      for s, ar, gs in zip(scales, aspect_ratios, grid_sizes):
          s, ar = np.array(s), np.array(ar)
          h_ratios = np.sqrt(ar)
          w_ratios = 1 / h_ratios
          ws = (w_ratios[:, None] * s[None, :]).reshape(-1)
          hs = (h_ratios[:, None] * s[None, :]).reshape(-1)
          base_anchors = (
              np.stack([-ws, -hs, ws, hs], axis=1) / 2
          ).round()
          stride_h, stride_w = (
              input_size[0] // gs[0],
              input_size[1] // gs[1],
          )
          shifts_x, shifts_y = np.meshgrid(
              np.arange(gs[1]) * stride_w, np.arange(gs[0]) * stride_h
          )
          shifts_x = shifts_x.reshape(-1)
          shifts_y = shifts_y.reshape(-1)
          shifts = np.stack(
              [shifts_x, shifts_y, shifts_x, shifts_y],
              axis=1,
              dtype=np.float32,
          )
          anchors.append(
              (shifts[:, None] + base_anchors[None, :]).reshape(-1, 4)
          )
      return anchors
  
imports: import math
  from tinygrad.helpers import flatten, get_child
  import tinygrad.nn
  from extra.models.resnet import ResNet
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: generate_anchors(input_size, grid_sizes, scales, aspect_ratios) and returns: anchors