import torch


def cart2pol(x, y):
    """
    Cartesian coordinates to polar coordinates.

    :param x:
    :param y:
    :return: r, phi
    """
    r = torch.sqrt(x ** 2 + y ** 2)
    phi = torch.atan2(y, x)
    return r, phi