(dims, origin=0.5)
return corners
generate relative box corners based on length per dim and
    origin point. 
    
    Args:
        dims (float array, shape=[N, ndim]): array of length per dim
        origin (list or array or float): origin point relate to smallest point.
        dtype (output dtype, optional): Defaults to np.float32 
    
    Returns:
        float array, shape=[N, 2 ** ndim, ndim]: returned corners. 
        point layout example: (2d) x0y0, x0y1, x1y0, x1y1;
            (3d) x0y0z0, x0y0z1, x0y1z0, x0y1z1, x1y0z0, x1y0z1, x1y1z0, x1y1z1
            where x0 < x1, y0 < y1, z0 < z1
generate relative box corners based on length per dim and
    origin point. 
    
    Args:
        dims (float array, shape=[N, ndim]): array of length per dim
        origin (list or array or float): origin point relate to smallest point.
        dtype (output dtype, optional): Defaults to np.float32 
    
    Returns:
        float array, shape=[N, 2 ** ndim, ndim]: returned corners. 
        point layout example: (2d) x0y0, x0y1, x1y0, x1y1;
            (3d) x0y0z0, x0y0z1, x0y1z0, x0y1z1, x1y0z0, x1y0z1, x1y1z0, x1y1z1
            where x0 < x1, y0 < y1, z0 < z1
generate relative box corners based on length per dim and origin point . Args : dims ( float array shape = [ N ndim ] ) : array of length per dim origin ( list or array or float ) : origin point relate to smallest point . dtype ( output dtype optional ) : Defaults to np . float32 Returns : float array shape = [ N 2 ** ndim ndim ] : returned corners . point layout example : ( 2d ) x0y0 x0y1 x1y0 x1y1 ; ( 3d ) x0y0z0 x0y0z1 x0y1z0 x0y1z1 x1y0z0 x1y0z1 x1y1z0 x1y1z1 where x0 < x1 y0 < y1 z0 < z1
def corners_nd(dims, origin=0.5):
    """generate relative box corners based on length per dim and
    origin point. 
    
    Args:
        dims (float array, shape=[N, ndim]): array of length per dim
        origin (list or array or float): origin point relate to smallest point.
        dtype (output dtype, optional): Defaults to np.float32 
    
    Returns:
        float array, shape=[N, 2 ** ndim, ndim]: returned corners. 
        point layout example: (2d) x0y0, x0y1, x1y0, x1y1;
            (3d) x0y0z0, x0y0z1, x0y1z0, x0y1z1, x1y0z0, x1y0z1, x1y1z0, x1y1z1
            where x0 < x1, y0 < y1, z0 < z1
    """
    ndim = int(dims.shape[1])
    dtype = torch_to_np_dtype(dims.dtype)
    if isinstance(origin, float):
        origin = [origin] * ndim
    corners_norm = np.stack(
        np.unravel_index(np.arange(2**ndim), [2] * ndim), axis=1).astype(dtype)
    # now corners_norm has format: (2d) x0y0, x0y1, x1y0, x1y1
    # (3d) x0y0z0, x0y0z1, x0y1z0, x0y1z1, x1y0z0, x1y0z1, x1y1z0, x1y1z1
    # so need to convert to a format which is convenient to do other computing.
    # for 2d boxes, format is clockwise start from minimum point
    # for 3d boxes, please draw them by your hand.
    if ndim == 2:
        # generate clockwise box corners
        corners_norm = corners_norm[[0, 1, 3, 2]]
    elif ndim == 3:
        corners_norm = corners_norm[[0, 1, 3, 2, 4, 5, 7, 6]]
    corners_norm = corners_norm - np.array(origin, dtype=dtype)
    corners_norm = torch.from_numpy(corners_norm).type_as(dims)
    corners = dims.view(-1, 1, ndim) * corners_norm.view(1, 2**ndim, ndim)
    return corners
def corners_nd ( dims , origin = 0.5 ) : ndim = int ( dims . shape [ 1 ] ) dtype = torch_to_np_dtype ( dims . dtype ) if isinstance ( origin , float ) : origin = [ origin ] * ndim corners_norm = np . stack ( np . unravel_index ( np . arange ( 2 ** ndim ) , [ 2 ] * ndim ) , axis = 1 ) . astype ( dtype ) # now corners_norm has format: (2d) x0y0, x0y1, x1y0, x1y1 # (3d) x0y0z0, x0y0z1, x0y1z0, x0y1z1, x1y0z0, x1y0z1, x1y1z0, x1y1z1 # so need to convert to a format which is convenient to do other computing. # for 2d boxes, format is clockwise start from minimum point # for 3d boxes, please draw them by your hand. if ndim == 2 : # generate clockwise box corners corners_norm = corners_norm [ [ 0 , 1 , 3 , 2 ] ] elif ndim == 3 : corners_norm = corners_norm [ [ 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 ] ] corners_norm = corners_norm - np . array ( origin , dtype = dtype ) corners_norm = torch . from_numpy ( corners_norm ) . type_as ( dims ) corners = dims . view ( - 1 , 1 , ndim ) * corners_norm . view ( 1 , 2 ** ndim , ndim ) return corners