def atan2(y, x, context=None):
    """
    Return ``atan(y / x)`` with the appropriate choice of function branch.

    If ``x > 0``, then ``atan2(y, x)`` is mathematically equivalent to ``atan(y
    / x)``.  If ``x < 0`` and ``y > 0``, ``atan(y, x)`` is equivalent to ``π +
    atan(y, x)``.  If ``x < 0`` and ``y < 0``, the result is ``-π + atan(y,
    x)``.

    Geometrically, ``atan2(y, x)`` is the angle (measured counterclockwise, in
    radians) from the positive x-axis to the line segment joining (0, 0) to (x,
    y), in the usual representation of the x-y plane.

    Special values are handled as described in the ISO C99 and IEEE 754-2008
    standards for the atan2 function.  The following examples illustrate the
    rules for positive y; for negative y, apply the symmetry ``atan(-y, x) ==
    -atan(y, x)``.

        >>> finite = positive = 2.3
        >>> negative = -2.3
        >>> inf = BigFloat('inf')

        >>> print(atan2(+0.0, -0.0))     # pi
        3.1415926535897931
        >>> print(atan2(+0.0, +0.0))     # 0
        0
        >>> print(atan2(+0.0, negative)) # pi
        3.1415926535897931
        >>> print(atan2(+0.0, positive)) # 0
        0
        >>> print(atan2(positive, 0.0))  # pi / 2
        1.5707963267948966
        >>> print(atan2(inf, -inf))      # 3*pi / 4
        2.3561944901923448
        >>> print(atan2(inf, inf))       # pi / 4
        0.78539816339744828
        >>> print(atan2(inf, finite))    # pi / 2
        1.5707963267948966
        >>> print(atan2(positive, -inf)) # pi
        3.1415926535897931
        >>> print(atan2(positive, +inf)) # 0
        0

    """
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_atan2,
        (
            BigFloat._implicit_convert(y),
            BigFloat._implicit_convert(x),
        ),
        context,
    )