import torch


def transform(boxes, transform_param):
    """
    transform boxes
    :param boxes: (n, 4) tensor, (cx, cy, w, h) form.
    :param transform_param: (n, 4) tensor.
    :return: (n, 4) transformed boxes, (cx, cy, w, h) form.
    """

    cx = boxes[:, 0] + transform_param[:, 0] * boxes[:, 2]
    cy = boxes[:, 1] + transform_param[:, 1] * boxes[:, 3]
    w = boxes[:, 2] * torch.exp(transform_param[:, 2])
    h = boxes[:, 3] * torch.exp(transform_param[:, 3])

    return torch.stack([cx, cy, w, h], 1)