code: def anchors_for_shape(
      image_shape,
      pyramid_levels=None,
      anchor_params=None,
      shapes_callback=None,
  ):
      """Generators anchors for a given shape.
  
      Args
          image_shape: The shape of the image.
          pyramid_levels: List of ints representing which pyramids to use (defaults to [3, 4, 5, 6, 7]).
          anchor_params: Struct containing anchor parameters. If None, default values are used.
          shapes_callback: Function to call for getting the shape of the image at different pyramid levels.
  
      Returns
          np.array of shape (N, 4) containing the (x1, y1, x2, y2) coordinates for the anchors.
      """
  
      if pyramid_levels is None:
          pyramid_levels = [3, 4, 5, 6, 7]
  
      if anchor_params is None:
          anchor_params = AnchorParameters.default
  
      if shapes_callback is None:
          shapes_callback = guess_shapes
      image_shapes = shapes_callback(image_shape, pyramid_levels)
  
      # compute anchors over all pyramid levels
      all_anchors = np.zeros((0, 4))
      for idx, p in enumerate(pyramid_levels):
          anchors = generate_anchors(
              base_size=anchor_params.sizes[idx],
              ratios=anchor_params.ratios,
              scales=anchor_params.scales,
          )
          shifted_anchors = shift(
              image_shapes[idx], anchor_params.strides[idx], anchors
          )
          all_anchors = np.append(all_anchors, shifted_anchors, axis=0)
  
      return all_anchors
  
file_path: ImageAI/imageai_tf_deprecated/Detection/keras_retinanet/utils/anchors.py
imports: import numpy
  from tensorflow import keras
label_desc: Use image node_id 5 for calling a global function with example usage: anchors_for_shape(image_shape, pyramid_levels, anchor_params, shapes_callback) and returns: all_anchors