def apply_tuple(tup, fn):
        """Apply a function to a Tensor or a tuple of Tensor"""
        if isinstance(tup, tuple):
            return tuple((fn(x) if isinstance(x, torch.Tensor) else x) for x in tup)
        else:
            return fn(tup)
Apply a function to a Tensor or a tuple of Tensor
analyze/convnexts4nd/src/models/sequence/rnns/rnn.py