parameters: (inf_or_nan=None)
return_statement: return old_settings
docstring: Set how abnormal conditions are handled by the default eager context.
  
    Example:
    ```python
    tfe.seterr(inf_or_nan="raise")
    a = tf.constant(10.0)
    b = tf.constant(0.0)
    try:
      c = a / b  # <-- Raises InfOrNanError.
    except Exception as e:
      print("Caught Exception: %s" % e)
  
    tfe.seterr(inf_or_nan="ignore")
    c = a / b  # <-- Does NOT raise exception anymore.
    ```
  
    Args:
      inf_or_nan: Set action for infinity (`inf`) and NaN (`nan`) values.
        Possible values: `{"ignore", "print", "raise", "warn"}`.
        `"ignore"`: take no action when `inf` values appear.
        `"print"`: print a warning to `stdout`.
        `"raise"`: raise an `InfOrNanError`.
        `"warn"`: print a warning using `tf.logging.warn`.
        A value of `None` leads to no change in the action of the condition.
  
    Returns:
      A dictionary of old actions.
  
    Raises:
      ValueError: If the value of any keyword arguments is invalid.
docstring_summary: Set how abnormal conditions are handled by the default eager context.
docstring_tokens: Set how abnormal conditions are handled by the default eager context .
function: def seterr(inf_or_nan=None):
    """Set how abnormal conditions are handled by the default eager context.
  
    Example:
    ```python
    tfe.seterr(inf_or_nan="raise")
    a = tf.constant(10.0)
    b = tf.constant(0.0)
    try:
      c = a / b  # <-- Raises InfOrNanError.
    except Exception as e:
      print("Caught Exception: %s" % e)
  
    tfe.seterr(inf_or_nan="ignore")
    c = a / b  # <-- Does NOT raise exception anymore.
    ```
  
    Args:
      inf_or_nan: Set action for infinity (`inf`) and NaN (`nan`) values.
        Possible values: `{"ignore", "print", "raise", "warn"}`.
        `"ignore"`: take no action when `inf` values appear.
        `"print"`: print a warning to `stdout`.
        `"raise"`: raise an `InfOrNanError`.
        `"warn"`: print a warning using `tf.logging.warn`.
        A value of `None` leads to no change in the action of the condition.
  
    Returns:
      A dictionary of old actions.
  
    Raises:
      ValueError: If the value of any keyword arguments is invalid.
    """
    if inf_or_nan not in _VALID_CALLBACK_ACTIONS:
      raise ValueError(
          "Invalid action value for inf_or_nan: %s. "
          "Valid actions are %s." % (inf_or_nan, _VALID_CALLBACK_ACTIONS))
  
    old_settings = {"inf_or_nan": "ignore"}
    default_context = context.get_default_context()
  
    carryover_callbacks = []
    for callback in default_context.post_execution_callbacks:
      # Check whether the callback is inf_nan_callback or a partial object of
      # inf_nan_callback.
      if (callback == inf_nan_callback or
          isinstance(callback, functools.partial) and
          callback.func == inf_nan_callback):
        if callback == inf_nan_callback:
          old_settings["inf_or_nan"] = _DEFAULT_CALLBACK_ACTION
        else:
          old_settings["inf_or_nan"] = callback.keywords.get(
              "action", _DEFAULT_CALLBACK_ACTION)
      elif inf_or_nan is not None:
        carryover_callbacks.append(callback)
  
    if inf_or_nan is not None:
      default_context.clear_post_execution_callbacks()
      for callback in carryover_callbacks:
        default_context.add_post_execution_callback(callback)
      if inf_or_nan != "ignore":
        default_context.add_post_execution_callback(
            functools.partial(inf_nan_callback, action=inf_or_nan))
  
    return old_settings
function_tokens: def seterr ( inf_or_nan = None ) : if inf_or_nan not in _VALID_CALLBACK_ACTIONS : raise ValueError ( "Invalid action value for inf_or_nan: %s. " "Valid actions are %s." % ( inf_or_nan , _VALID_CALLBACK_ACTIONS ) ) old_settings = { "inf_or_nan" : "ignore" } default_context = context . get_default_context ( ) carryover_callbacks = [ ] for callback in default_context . post_execution_callbacks : # Check whether the callback is inf_nan_callback or a partial object of # inf_nan_callback. if ( callback == inf_nan_callback or isinstance ( callback , functools . partial ) and callback . func == inf_nan_callback ) : if callback == inf_nan_callback : old_settings [ "inf_or_nan" ] = _DEFAULT_CALLBACK_ACTION else : old_settings [ "inf_or_nan" ] = callback . keywords . get ( "action" , _DEFAULT_CALLBACK_ACTION ) elif inf_or_nan is not None : carryover_callbacks . append ( callback ) if inf_or_nan is not None : default_context . clear_post_execution_callbacks ( ) for callback in carryover_callbacks : default_context . add_post_execution_callback ( callback ) if inf_or_nan != "ignore" : default_context . add_post_execution_callback ( functools . partial ( inf_nan_callback , action = inf_or_nan ) ) return old_settings