def METHOD_NAME(prob: Tensor, smoothing: Union[Tensor, float], *, axis: Optional[Dim] = None) -> Tensor:
    """
    Label smoothing, often used for cross entropy.
    In case of sparse data, it will become dense (via :func:`smooth_one_hot`)
    and the target label will get probability (1 - smoothing).
    """
    if not axis:
        assert prob.feature_dim or prob.sparse_dim
        axis = prob.feature_dim or prob.sparse_dim
    if prob.sparse_dim:
        assert prob.sparse_dim == axis
        return rf.smooth_one_hot(prob, label_prob=1.0 - smoothing)
    else:
        assert axis in prob.dims_set
        # Make it consistent to the sparse case.
        # Value of 1.0 should result in (1 - smoothing).
        # Value of 0.0 should result in smoothing / (dim - 1).
        # Sum over all should still remain 1.0.
        dim = axis.dimension
        floor_prob = smoothing / (dim - 1)
        factor = 1.0 - dim * floor_prob
        # Case for prob[i] == 0 is clear.
        # Case for prob[i] == 1: 1 - dim * floor_prob + floor_prob = 1 + (1 - dim) * floor_prob = 1 - smoothing
        # Sum over all: 1 - dim * floor_prob + floor_prob * dim = 1
        return prob * factor + floor_prob