parameters: (x, name="log_cosh")
docstring: Logarithm of hyperbolic cosine:  `log_cosh(x) = Log[(e**x + e**-x) / 2]`.
  
    Args:
      x:  Numeric `Tensor`.
      name:  A string name to prepend to created Ops.
  
    Returns:
      Numeric `Tensor` of same `shape` and `dtype` as `x`.
docstring_summary: Logarithm of hyperbolic cosine:  `log_cosh(x) = Log[(e**x + e**-x) / 2]`.
docstring_tokens: Logarithm of hyperbolic cosine : log_cosh ( x ) = Log [ ( e ** x + e ** - x ) / 2 ] .
function: def log_cosh(x, name="log_cosh"):
    """Logarithm of hyperbolic cosine:  `log_cosh(x) = Log[(e**x + e**-x) / 2]`.
  
    Args:
      x:  Numeric `Tensor`.
      name:  A string name to prepend to created Ops.
  
    Returns:
      Numeric `Tensor` of same `shape` and `dtype` as `x`.
    """
    # For large |x| >> 1, e**x will become Inf.  So we need to approximate
    # Log[e**x + e**-x] approx |x|.
    # We also need to ensure that large |x| is never fed to the exponential func.
    with ops.name_scope(name):
      x = ops.convert_to_tensor(x, name="x")
      large_x_value = 0.9 * np.log(np.finfo(x.dtype.as_numpy_dtype).max)
      x_capped = clip_ops.clip_by_value(x, -large_x_value, large_x_value)
      return array_ops.where(
          math_ops.abs(x) > large_x_value,
          math_ops.abs(x) - np.log(2).astype(x.dtype.as_numpy_dtype),
          math_ops.log(cosh(x_capped)))
function_tokens: def log_cosh ( x , name = "log_cosh" ) : # For large |x| >> 1, e**x will become Inf.  So we need to approximate # Log[e**x + e**-x] approx |x|. # We also need to ensure that large |x| is never fed to the exponential func. with ops . name_scope ( name ) : x = ops . convert_to_tensor ( x , name = "x" ) large_x_value = 0.9 * np . log ( np . finfo ( x . dtype . as_numpy_dtype ) . max ) x_capped = clip_ops . clip_by_value ( x , - large_x_value , large_x_value ) return array_ops . where ( math_ops . abs ( x ) > large_x_value , math_ops . abs ( x ) - np . log ( 2 ) . astype ( x . dtype . as_numpy_dtype ) , math_ops . log ( cosh ( x_capped ) ) )