parameters: (grid_height, grid_width, scales, aspect_ratios, base_anchor_size, anchor_stride,
                   anchor_offset)
return_statement: return bbox_corners
docstring: Create a tiled set of anchors strided along a grid in image space.
    This op creates a set of anchor boxes by placing a "basis" collection of
    boxes with user-specified scales and aspect ratios centered at evenly
    distributed points along a grid.  The basis collection is specified via the
    scale and aspect_ratios arguments.  For example, setting scales=[.1, .2, .2]
    and aspect ratios = [2,2,1/2] means that we create three boxes: one with scale
    .1, aspect ratio 2, one with scale .2, aspect ratio 2, and one with scale .2
    and aspect ratio 1/2.  Each box is multiplied by "base_anchor_size" before
    placing it over its respective center.
    Grid points are specified via grid_height, grid_width parameters as well as
    the anchor_stride and anchor_offset parameters.
    Args:
      grid_height: size of the grid in the y direction (int or int scalar tensor)
      grid_width: size of the grid in the x direction (int or int scalar tensor)
      scales: a 1-d  (float) tensor representing the scale of each box in the
        basis set.
      aspect_ratios: a 1-d (float) tensor representing the aspect ratio of each
        box in the basis set.  The length of the scales and aspect_ratios tensors
        must be equal.
      base_anchor_size: base anchor size as [height, width]
        (float tensor of shape [2])
      anchor_stride: difference in centers between base anchors for adjacent grid
                     positions (float tensor of shape [2])
      anchor_offset: center of the anchor with scale and aspect ratio 1 for the
                     upper left element of the grid, this should be zero for
                     feature networks with only VALID padding and even receptive
                     field size, but may need some additional calculation if other
                     padding is used (float tensor of shape [2])
    Returns:
      a BoxList holding a collection of N anchor boxes
docstring_summary: Create a tiled set of anchors strided along a grid in image space.
    This op creates a set of anchor boxes by placing a "basis" collection of
    boxes with user-specified scales and aspect ratios centered at evenly
    distributed points along a grid.  The basis collection is specified via the
    scale and aspect_ratios arguments.  For example, setting scales=[.1, .2, .2]
    and aspect ratios = [2,2,1/2] means that we create three boxes: one with scale
    .1, aspect ratio 2, one with scale .2, aspect ratio 2, and one with scale .2
    and aspect ratio 1/2.  Each box is multiplied by "base_anchor_size" before
    placing it over its respective center.
    Grid points are specified via grid_height, grid_width parameters as well as
    the anchor_stride and anchor_offset parameters.
    Args:
      grid_height: size of the grid in the y direction (int or int scalar tensor)
      grid_width: size of the grid in the x direction (int or int scalar tensor)
      scales: a 1-d  (float) tensor representing the scale of each box in the
        basis set.
      aspect_ratios: a 1-d (float) tensor representing the aspect ratio of each
        box in the basis set.  The length of the scales and aspect_ratios tensors
        must be equal.
      base_anchor_size: base anchor size as [height, width]
        (float tensor of shape [2])
      anchor_stride: difference in centers between base anchors for adjacent grid
                     positions (float tensor of shape [2])
      anchor_offset: center of the anchor with scale and aspect ratio 1 for the
                     upper left element of the grid, this should be zero for
                     feature networks with only VALID padding and even receptive
                     field size, but may need some additional calculation if other
                     padding is used (float tensor of shape [2])
    Returns:
      a BoxList holding a collection of N anchor boxes
docstring_tokens: Create a tiled set of anchors strided along a grid in image space . This op creates a set of anchor boxes by placing a basis collection of boxes with user - specified scales and aspect ratios centered at evenly distributed points along a grid . The basis collection is specified via the scale and aspect_ratios arguments . For example setting scales = [ . 1 . 2 . 2 ] and aspect ratios = [ 2 2 1 / 2 ] means that we create three boxes : one with scale . 1 aspect ratio 2 one with scale . 2 aspect ratio 2 and one with scale . 2 and aspect ratio 1 / 2 . Each box is multiplied by base_anchor_size before placing it over its respective center . Grid points are specified via grid_height grid_width parameters as well as the anchor_stride and anchor_offset parameters . Args : grid_height : size of the grid in the y direction ( int or int scalar tensor ) grid_width : size of the grid in the x direction ( int or int scalar tensor ) scales : a 1 - d ( float ) tensor representing the scale of each box in the basis set . aspect_ratios : a 1 - d ( float ) tensor representing the aspect ratio of each box in the basis set . The length of the scales and aspect_ratios tensors must be equal . base_anchor_size : base anchor size as [ height width ] ( float tensor of shape [ 2 ] ) anchor_stride : difference in centers between base anchors for adjacent grid positions ( float tensor of shape [ 2 ] ) anchor_offset : center of the anchor with scale and aspect ratio 1 for the upper left element of the grid this should be zero for feature networks with only VALID padding and even receptive field size but may need some additional calculation if other padding is used ( float tensor of shape [ 2 ] ) Returns : a BoxList holding a collection of N anchor boxes
function: def tile_anchors(grid_height, grid_width, scales, aspect_ratios, base_anchor_size, anchor_stride,
                   anchor_offset):
      """Create a tiled set of anchors strided along a grid in image space.
    This op creates a set of anchor boxes by placing a "basis" collection of
    boxes with user-specified scales and aspect ratios centered at evenly
    distributed points along a grid.  The basis collection is specified via the
    scale and aspect_ratios arguments.  For example, setting scales=[.1, .2, .2]
    and aspect ratios = [2,2,1/2] means that we create three boxes: one with scale
    .1, aspect ratio 2, one with scale .2, aspect ratio 2, and one with scale .2
    and aspect ratio 1/2.  Each box is multiplied by "base_anchor_size" before
    placing it over its respective center.
    Grid points are specified via grid_height, grid_width parameters as well as
    the anchor_stride and anchor_offset parameters.
    Args:
      grid_height: size of the grid in the y direction (int or int scalar tensor)
      grid_width: size of the grid in the x direction (int or int scalar tensor)
      scales: a 1-d  (float) tensor representing the scale of each box in the
        basis set.
      aspect_ratios: a 1-d (float) tensor representing the aspect ratio of each
        box in the basis set.  The length of the scales and aspect_ratios tensors
        must be equal.
      base_anchor_size: base anchor size as [height, width]
        (float tensor of shape [2])
      anchor_stride: difference in centers between base anchors for adjacent grid
                     positions (float tensor of shape [2])
      anchor_offset: center of the anchor with scale and aspect ratio 1 for the
                     upper left element of the grid, this should be zero for
                     feature networks with only VALID padding and even receptive
                     field size, but may need some additional calculation if other
                     padding is used (float tensor of shape [2])
    Returns:
      a BoxList holding a collection of N anchor boxes
    """
      aspect_ratios = torch.as_tensor(aspect_ratios, dtype=torch.float32)
      scales = torch.as_tensor(scales, dtype=torch.float32)
  
      ratio_sqrts = torch.sqrt(aspect_ratios)
      heights = scales / ratio_sqrts * base_anchor_size[0]
      widths = scales * ratio_sqrts * base_anchor_size[1]
  
      # Get a grid of box centers
      y_centers = torch.arange(grid_height, dtype=torch.float32)
      y_centers = y_centers * anchor_stride[0] + anchor_offset[0]
      x_centers = torch.arange(grid_width, dtype=torch.float32)
      x_centers = x_centers * anchor_stride[1] + anchor_offset[1]
  
      x_centers, y_centers = meshgrid(x_centers, y_centers)
  
      widths_grid, x_centers_grid = meshgrid(widths, x_centers)
      heights_grid, y_centers_grid = meshgrid(heights, y_centers)
  
      bbox_centers = torch.stack([y_centers_grid, x_centers_grid], dim=3)
      bbox_sizes = torch.stack([heights_grid, widths_grid], dim=3)
      bbox_centers = torch.reshape(bbox_centers, [-1, 2])
      bbox_sizes = torch.reshape(bbox_sizes, [-1, 2])
      bbox_corners = _center_size_bbox_to_corners_bbox(bbox_centers, bbox_sizes)
      return bbox_corners
function_tokens: def tile_anchors ( grid_height , grid_width , scales , aspect_ratios , base_anchor_size , anchor_stride , anchor_offset ) : aspect_ratios = torch . as_tensor ( aspect_ratios , dtype = torch . float32 ) scales = torch . as_tensor ( scales , dtype = torch . float32 ) ratio_sqrts = torch . sqrt ( aspect_ratios ) heights = scales / ratio_sqrts * base_anchor_size [ 0 ] widths = scales * ratio_sqrts * base_anchor_size [ 1 ] # Get a grid of box centers y_centers = torch . arange ( grid_height , dtype = torch . float32 ) y_centers = y_centers * anchor_stride [ 0 ] + anchor_offset [ 0 ] x_centers = torch . arange ( grid_width , dtype = torch . float32 ) x_centers = x_centers * anchor_stride [ 1 ] + anchor_offset [ 1 ] x_centers , y_centers = meshgrid ( x_centers , y_centers ) widths_grid , x_centers_grid = meshgrid ( widths , x_centers ) heights_grid , y_centers_grid = meshgrid ( heights , y_centers ) bbox_centers = torch . stack ( [ y_centers_grid , x_centers_grid ] , dim = 3 ) bbox_sizes = torch . stack ( [ heights_grid , widths_grid ] , dim = 3 ) bbox_centers = torch . reshape ( bbox_centers , [ - 1 , 2 ] ) bbox_sizes = torch . reshape ( bbox_sizes , [ - 1 , 2 ] ) bbox_corners = _center_size_bbox_to_corners_bbox ( bbox_centers , bbox_sizes ) return bbox_corners