code: def generate_anchors_per_feat_map(
      feature_map_shape, anchor_reference
  ):
      """Generate anchor for an image.
  
      Using the feature map, the output of the pretrained network for an
      image, and the anchor_reference generated using the anchor config
      values. We generate a list of anchors.
  
      Anchors are just fixed bounding boxes of different ratios and sizes
      that are uniformly generated throught the image.
  
      Args:
          feature_map_shape: Shape of the convolutional feature map used as
              input for the RPN. Should be (batch, height, width, depth).
  
      Returns:
          all_anchors: A flattened Tensor with all the anchors of shape
              `(num_anchors_per_points * feature_width * feature_height, 4)`
              using the (x1, y1, x2, y2) convention.
      """
      with tf.variable_scope("generate_anchors"):
          shift_x = np.arange(feature_map_shape[1])
          shift_y = np.arange(feature_map_shape[0])
          shift_x, shift_y = np.meshgrid(shift_x, shift_y)
  
          shift_x = np.reshape(shift_x, [-1])
          shift_y = np.reshape(shift_y, [-1])
  
          shifts = np.stack(
              [shift_x, shift_y, shift_x, shift_y], axis=0
          )
  
          shifts = np.transpose(shifts)
          # Shifts now is a (H x W, 4) Tensor
  
          # Expand dims to use broadcasting sum.
          all_anchors = np.expand_dims(
              anchor_reference, axis=0
          ) + np.expand_dims(shifts, axis=1)
          # Flatten
          return np.reshape(all_anchors, (-1, 4))
  
imports: import numpy
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: generate_anchors_per_feat_map(feature_map_shape, anchor_reference) and returns: np