import math


def _rescale_path(path, depth):
    """Rescales the input path by depth! ** (1 / depth), so that the last
    signature term should be roughly O(1).

    Parameters
    ----------
    path : np.ndarray
        Input path of shape [N, L, C].
    depth : int
        Depth the signature will be computed to.

    Returns
    -------
    np.ndarray:
        Tensor of the same shape as path, corresponding to the scaled path.
    """
    coeff = math.factorial(depth) ** (1 / depth)
    return coeff * path