def dargsort(original, sortd, sigma, transpose=False):
    """Take an input vector `original` and a sorted vector `sortd`
    along with an RBF kernel width `sigma`, return an approximate ranking.
    If transpose is True, returns approximate argsort (but note that ties have identical values)
    If transpose is False (default), returns ranking"""
    order = order_matrix(original, sortd, sigma=sigma)
    if transpose:
        order = order.T
    return order @ np.arange(len(original))
def diff_argsort(matrices, x, sigma=0.1, softmax=softmax):
    """Return the smoothed, differentiable ranking of each element of x. Sigma
    specifies the smoothing of the ranking. """
    sortd = diff_sort(matrices, x, softmax)
    return order_matrix(x, sortd, sigma=sigma) @ np.arange(len(x))
def dargsort(original, sortd, sigma, transpose=False):
    order = order_matrix(original, sortd, sigma=sigma)
    if transpose:
        order = order.T
    return order @ np.arange(len(original))