import torch


def forward(model, X):
    """General function for applying the same model at multiple time steps"""
    output_list = []
    for i in range(X.size(1)):
        output = model(X[:,i:i+1,...])
        if isinstance(output, tuple):
            output = output[0]
        output_list.append(output)
    output_seq = torch.cat(output_list, 1)
    return output_seq