def seg_length(segments):
    """
    Computes the lengths of a set of bounding segments, which are specified by its
    (x1, x2) coordinates.

    Arguments:
        segments (Tensor[N, 2]): segments for which the length will be computed. They
            are expected to be in (x1 x2) format

    Returns:
        length (Tensor[N]): length for each segment
    """
    return segments[:, 1] - segments[:, 0]