code: def assert_finite(x, summarize=None, message=None, name=None):
      """Assert all elements of `x` are finite.
  
      Args:
        x:  Numeric `Tensor`.
        summarize: Print this many entries of each tensor.
        message: A string to prefix to the default message.
        name: A name for this operation (optional).
          Defaults to "assert_finite".
  
      Returns:
        Op raising `InvalidArgumentError` unless `x` has specified rank or lower.
        If static checks determine `x` has correct rank, a `no_op` is returned.
  
      Raises:
        ValueError: If static checks determine `x` is not finite.
      """
      with tf.name_scope(name or "assert_finite"):
          if message is None:
              message = "`Tensor` contained non-finite values."
          x = tf.convert_to_tensor(x)
          x_ = tf.get_static_value(x)
          if x_ is not None:
              if ~np.all(np.isfinite(x_)):
                  raise ValueError(message)
              return x
          assertion = tf.debugging.assert_equal(
              tf.math.is_finite(x),
              tf.ones_like(x, tf.bool),
              summarize=summarize,
              message=message,
          )
          with tf.control_dependencies([assertion]):
              return tf.identity(x)
  
imports: import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 1 for calling a global function with example usage: assert_finite(x, summarize, message, name) and returns: x, tf