def flatten_model_as_list(model):
    """
    Returns a list of submodules from a given Pytorch model
    """
    current_modules = []
    if len(model._modules) > 0:
        queue = model._modules
        while len(queue) > 0:
            sub_model = queue.popitem(False)[1]
            current_modules = current_modules + flatten_model_as_list(sub_model)
    else:
        current_modules.append(model)
    return current_modules