import torch


def complex_packed_to_planar(data):
    """
        Expects shape: ... x height x width x 2
        Returns shape: ... x 2 x height x width
    """
    assert data.shape[-1] == 2
    real = data[..., 0]
    imaginary = data[..., 1]
    return torch.stack([real, imaginary], dim=-3)