<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_polar(x, y, theta_units="radians"):
 """ Converts cartesian x, y to polar r, theta. """

    assert theta_units in [
        "radians",
        "degrees",
    ], "kwarg theta_units must specified in radians or degrees"

    theta = atan2(y, x)
    r = sqrt(x ** 2 + y ** 2)

    if theta_units == "degrees":
        theta = to_degrees(theta)

    return r, theta