import torch


def apply_trans(x, trans):
    """Apply spatial transformations to input

    Attributes:
        x (torch.Tensor): Input Tensor
        trans (torch.nn.Module): Spatial Transformer module

    Returns:
        torch.Tensor: Output Tensor

    """
    x = x.transpose(2, 1)
    x = torch.bmm(x, trans)
    x = x.transpose(2, 1)
    return x