import torch


def matrix_revert_coordinate_order(batch: torch.Tensor) -> torch.Tensor:
    """
    Reverts the coordinate order of a matrix (e.g. from xyz to zyx).

    Args:
        batch: the batched transformation matrices; Should be of shape
            BATCHSIZE x NDIM x NDIM

    Returns:
        torch.Tensor: the matrix performing the same transformation on vectors with a
            reversed coordinate order
    """
    batch[:, :-1, :] = batch[:, :-1, :].flip(1).clone()
    batch[:, :-1, :-1] = batch[:, :-1, :-1].flip(2).clone()
    return batch