(static, tour_indices)
return tour_len.sum(1).detach()
Parameters
    ----------
    static: torch.FloatTensor containing static (e.g. x, y) data
    tour_indices: torch.IntTensor of size (batch_size, num_cities)

    Returns
    -------
    Euclidean distance between consecutive nodes on the route. of size
    (batch_size, num_cities)
Parameters
    ----------
    static: torch.FloatTensor containing static (e.g. x, y) data
    tour_indices: torch.IntTensor of size (batch_size, num_cities)
Parameters ---------- static : torch . FloatTensor containing static ( e . g . x y ) data tour_indices : torch . IntTensor of size ( batch_size num_cities )
def reward(static, tour_indices):
    """
    Parameters
    ----------
    static: torch.FloatTensor containing static (e.g. x, y) data
    tour_indices: torch.IntTensor of size (batch_size, num_cities)

    Returns
    -------
    Euclidean distance between consecutive nodes on the route. of size
    (batch_size, num_cities)
    """

    # Convert the indices back into a tour
    idx = tour_indices.unsqueeze(1).expand_as(static)
    tour = torch.gather(static.data, 2, idx).permute(0, 2, 1)

    # Make a full tour by returning to the start
    y = torch.cat((tour, tour[:, :1]), dim=1)

    # Euclidean distance between each consecutive point
    tour_len = torch.sqrt(torch.sum(torch.pow(y[:, :-1] - y[:, 1:], 2), dim=2))

    return tour_len.sum(1).detach()
def reward ( static , tour_indices ) : # Convert the indices back into a tour idx = tour_indices . unsqueeze ( 1 ) . expand_as ( static ) tour = torch . gather ( static . data , 2 , idx ) . permute ( 0 , 2 , 1 ) # Make a full tour by returning to the start y = torch . cat ( ( tour , tour [ : , : 1 ] ) , dim = 1 ) # Euclidean distance between each consecutive point tour_len = torch . sqrt ( torch . sum ( torch . pow ( y [ : , : - 1 ] - y [ : , 1 : ] , 2 ) , dim = 2 ) ) return tour_len . sum ( 1 ) . detach ( )