import torch


def quat_conjugate(a: torch.Tensor) -> torch.Tensor:
    """Computes the conjugate of a quaternion.

    Args:
        a: quaternion to compute conjugate of, shape (N, 4)
    Returns:
        Conjugated `a`, shape (N, 4)

    """
    shape = a.shape
    a = a.reshape(-1, 4)
    return torch.cat((-a[:, :3], a[:, -1:]), dim=-1).view(shape)