//  [python]
def get_k_lowest_eig_old(adj, k, normalize_L):
    r"""
    Compute the k-lowest eigenvalues and eigenvectors of the Laplacian matrix
    for each connected components of the graph.
    Parameters
    --------------
        adj: tensor(..., N, N)
            Batches of symmetric adjacency matrices
        k: int
            Compute the k-th smallest eigenvectors and eigenvalues.
        
        normalize_L: bool
            Whether to normalize the Laplacian matrix
            If `False`, then `L = D - A`
            If `True`, then `L = D^-1 (D - A)`
    Returns
    -------------
        eigval: tensor(..., k)
            Resulting k-lowest eigenvalues of the Laplacian matrix,
            with the same batching as the `adj` tensor
        eigvec: tensor(..., N, k)
            Resulting k-lowest eigenvectors of the Laplacian matrix,
            with the same batching as the `adj` tensor.
            The dim==-1 represents the k-th vectors.
            The dim==-2 represents the N elements of each vector. 
    """

    device = adj.device
    # Reshape as a 3D tensor for easier looping along batches
    shape = list(adj.shape)
    if adj.ndim == 2:
        adj = adj.unsqueeze(0)
    elif adj.ndim > 3:
        adj = adj.view(-1, shape[-2], shape[-1])

    L = get_laplacian_matrix(adj, normalize_L=False)
    
    eigvec = torch.zeros(adj.shape[0],adj.shape[-1],k).to(device)
    for ii in range(adj.shape[0]):
        #get singular values decomposition
        u,s,v = torch.linalg.svd(L[ii])
        #get 0 singular values positions in svd
        null_mask = (s <= EPS)
        #get basis of 0 singular space
        zero_eig_vect = torch.transpose(v[null_mask],0,1)
        assert zero_eig_vect.shape[0] == adj.shape[-1]
        
        
        components = []
        for jj in range(zero_eig_vect.shape[-1]):
            #get the indices of the connected components by getting nonzero entries in the 
            #0 singular vector associated to the component
            compo = torch.nonzero(zero_eig_vect[:,jj]).squeeze()
            components.append(compo)

        #get the eigenvalues and eigenvectors of each components
        ii_eigvec = torch.zeros(adj.shape[-1],k).to(device)
        for jj, compo in enumerate(components):
            #select the sub matrix corresponding to the component
            sub_adj = adj[ii,:,:][compo].T[compo].T
            
            #if a component has only one node, all eigen vectors are 0
            if sub_adj.shape==torch.Size([]):
                compo_eigvec = torch.zeros(1,k)
                ii_eigvec[compo,:] = compo_eigvec
            else:
                dim = sub_adj.shape[0]
                #if the components Laplacian has less eigenvectors than k, add zero vectors in padding
                if k > dim:
                    compo_eigval, compo_eigvec = get_k_lowest_eig(sub_adj, dim, normalize_L)
                    compo_eigvec = torch.cat((compo_eigvec, torch.zeros(1, dim, k-dim, device=device)), dim=2)

                else:
                    compo_eigval, compo_eigvec = get_k_lowest_eig_connected(sub_adj, k, normalize_L)
                
                #place the k eigenvectors of each component in a vector using the indices of each nodes 
                #of the components nodes
                ii_eigvec[compo,:] = compo_eigvec
        eigvec[ii,:,:]=ii_eigvec

    #makes sense for connected graphs but not for disconnected ones so it is left empty. Remove later
    eigval = []

    return eigval, eigvec