import torch


def merge_lists(input_list):
    """
    input_list = list:time[ list:level[4D tensor] ]
    output_list = list:level[ 4D tensor (batch*time, channel, height, width)]
    """
    len_tt = len(input_list)
    len_ll = len(input_list[0])

    output_list = []
    for ll in range(len_ll):
        list_ll = []
        for tt in range(len_tt):
            list_ll.append(input_list[tt][ll])            
        tensor_ll = torch.stack(list_ll, dim=1)
        tbb, ttt, tcc, thh, tww = tensor_ll.size()
        output_list.append(tensor_ll.reshape(tbb * ttt, tcc, thh, tww))

    return output_list