def split_TT(M, dims, ranks, rng):
    """


    Parameters
    ----------
    M : numpy array
        Tensor or possible matrix. Boolean numpy array.
    dims : list
        list of dimensions.
    ranks : list
        list of ranks.
    rng : range
        range of indexes in the dimension list.

    Returns
    -------
    dim : int 
        product of dimensions in rng.
    list
        list of a subset (in rng) of dimensionss.
    list
        list of a subset (in rng) of ranks.

    """
    dim = 1
    for i in rng:
        dim *= dims[i]
    return dim, [dims[i] for i in rng], [ranks[i] for i in rng]