import torch


def double_parameters(parameters: torch.Tensor) -> torch.Tensor:
    """Double parameters as (A, B, C, D) --> (A, B, A, B, C, D, C, D) etc

    Args:
        parameters: Parameter vectors (n_batch, n_parameters).

    Returns:
        parameters with shape (2*n_batch, n_parameters).
    """
    n_batch, n_parameters = parameters.shape
    assert n_batch % 2 == 0, "n_batch must be divisible by two."
    out = torch.repeat_interleave(parameters.view(-1, 2 * n_parameters), 2, dim=0).view(
        -1, n_parameters
    )
    return out