Sure.
def pad_matrix(X):
    '''
    Input: X has shape(1, D)
           For Example, input X should be X_test_Distance[0,:].reshape(1,-1)
    '''
    width = []
    height = []
    for j in range(X.shape[1]):
        h = X[0,j].shape[0]
        w = X[0,j].shape[1]
        width.append(w)
        height.append(h)

    w_max_idx = np.argmax(width)
    h_max_idx = np.argmax(height)
    w_max = width[w_max_idx]
    h_max = height[h_max_idx]

    for j in range(X.shape[1]):
        X[0,j] = np.pad(X[0,j], ((0,h_max - X[0,j].shape[0]),(0, w_max - X[0,j].shape[1])), 'constant')
    return X

def stack_coo_matrix(X):
    '''
    Input: X has shape(1, D)
           For Example, input X should be X_test_Distance[0,:].reshape(1,-1)
           Example code: D = stack_coo_matrix(X_test_Distance[2,:].reshape(1,-1))
    '''
    Temp = pad_matrix(X)
    output = coo_matrix(Temp[0,0])
    # print(output)
    for i in range(X.shape[1] - 1):
        output = hstack([output, coo_matrix(Temp[0,i+1])])
    return output

def sparse2tensor(X):
    '''
    Input: X has shape(1, D)
           For Example, input X should be X_test_Distance[0,:].reshape(1,-1)
    '''
    D_in = X.shape[1]
    sparse =  stack_coo_matrix(X)
    matrix = sparse.toarray()
    D_total = matrix.shape[1]
    matrix = matrix.reshape(int(D_in), -1, int(D_total/D_in))
    tensor = torch.tensor(matrix, device=device, dtype=dtype)
    return tensor

And I shared the sample example for X on Google Dirve.
https://drive.google.com/file/d/1oF7vr7WnOf6Fu9tlrsEyK4zPG4QrWOVg/view?usp=sharing 1
Thank you so much!