import torch


def to_concatenated_real(input, flatten=None, dim=-1):
    """Map real tensor input `... x [2 * D]` to a pair (re, im) with dim `... x D`."""
    assert flatten is None
    return torch.cat([input.real, input.imag], dim=dim)