def concat_tuple(tups, dim=0):
        """Concat a list of Tensors or a list of tuples of Tensor."""
        if isinstance(tups[0], tuple):
            return tuple(
                (torch.cat(xs, dim) if isinstance(xs[0], torch.Tensor) else xs[0])
                for xs in zip(*tups)
            )
        else:
            return torch.cat(tups, dim)
Concat a list of Tensors or a list of tuples of Tensor.
analyze/convnexts4nd/src/models/sequence/rnns/rnn.py