import tensorflow as tf


  with tf.variable_scope('anchor_generator'):
    if offset is None:
      offset = [stride[0]/2, stride[1]/2]

    features_width = tf.cast(features_width, tf.int32)
    features_height = tf.cast(features_height, tf.int32)
    scales = tf.convert_to_tensor(scales, dtype=tf.float32)
    ratios = tf.convert_to_tensor(ratios, dtype=tf.float32)
    offset = tf.convert_to_tensor(offset, dtype=tf.float32)

    scales_grid, ratios_grid = tf.meshgrid(scales,
                                           ratios)

    scales_grid = tf.reshape(scales_grid, [-1, 1])
    ratios_grid = tf.reshape(ratios_grid, [-1, 1])

    ratio_sqrts = tf.sqrt(ratios_grid)

    heights = scales_grid / ratio_sqrts * base_size[1]
    widths = scales_grid * ratio_sqrts * base_size[0]

    x_centers = tf.cast(tf.range(features_width), tf.float32)
    x_centers = x_centers * stride[1]
    y_centers = tf.cast(tf.range(features_height), tf.float32)
    y_centers = y_centers * stride[0]
    # x_centers = x_centers + offset[1]
    # y_centers = y_centers + offset[0]

    x_centers, y_centers = tf.meshgrid(x_centers, y_centers)
