def log_ndtr(x, series_order=<NUM_LIT:3>, name="<STR_LIT>"):
if not isinstance(series_order, int):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if series_order < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if series_order > <NUM_LIT:30>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>with tf.name_scope(name):<EOL><INDENT>x = tf.convert_to_tensor(value=x, name="<STR_LIT:x>")<EOL>if dtype_util.base_equal(x.dtype, tf.float64):<EOL><INDENT>lower_segment = LOGNDTR_FLOAT64_LOWER<EOL>upper_segment = LOGNDTR_FLOAT64_UPPER<EOL><DEDENT>elif dtype_util.base_equal(x.dtype, tf.float32):<EOL><INDENT>lower_segment = LOGNDTR_FLOAT32_LOWER<EOL>upper_segment = LOGNDTR_FLOAT32_UPPER<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>" % x.dtype)<EOL><DEDENT>return tf.where(<EOL>tf.greater(x, upper_segment),<EOL>-_ndtr(-x),  <EOL>tf.where(<EOL>tf.greater(x, lower_segment),<EOL>tf.math.log(_ndtr(tf.maximum(x, lower_segment))),<EOL>_log_ndtr_lower(tf.minimum(x, lower_segment), series_order)))<EOL><DEDENT>
Log Normal distribution function.

    For details of the Normal distribution function see `ndtr`.

    This function calculates `(log o ndtr)(x)` by either calling `log(ndtr(x))` or
    using an asymptotic series. Specifically:
    - For `x > upper_segment`, use the approximation `-ndtr(-x)` based on
      `log(1-x) ~= -x, x << 1`.
    - For `lower_segment < x <= upper_segment`, use the existing `ndtr` technique
      and take a log.
    - For `x <= lower_segment`, we use the series approximation of erf to compute
      the log CDF directly.

    The `lower_segment` is set based on the precision of the input:

    ```
    lower_segment = { -20,  x.dtype=float64
                    { -10,  x.dtype=float32
    upper_segment = {   8,  x.dtype=float64
                    {   5,  x.dtype=float32
    ```

    When `x < lower_segment`, the `ndtr` asymptotic series approximation is:

    ```
       ndtr(x) = scale * (1 + sum) + R_N
       scale   = exp(-0.5 x**2) / (-x sqrt(2 pi))
       sum     = Sum{(-1)^n (2n-1)!! / (x**2)^n, n=1:N}
       R_N     = O(exp(-0.5 x**2) (2N+1)!! / |x|^{2N+3})
    ```

    where `(2n-1)!! = (2n-1) (2n-3) (2n-5) ...  (3) (1)` is a
    [double-factorial](https://en.wikipedia.org/wiki/Double_factorial).


    Args:
      x: `Tensor` of type `float32`, `float64`.
      series_order: Positive Python `integer`. Maximum depth to
        evaluate the asymptotic expansion. This is the `N` above.
      name: Python string. A name for the operation (default="log_ndtr").

    Returns:
      log_ndtr: `Tensor` with `dtype=x.dtype`.

    Raises:
      TypeError: if `x.dtype` is not handled.
      TypeError: if `series_order` is a not Python `integer.`
      ValueError:  if `series_order` is not in `[0, 30]`.