class_docstr: Represents a value that may or may not be present.
  
  A `tf.experimental.Optional` can represent the result of an operation that may
  fail as a value, rather than raising an exception and halting execution. For
  example, `tf.data.Iterator.get_next_as_optional()` returns a
  `tf.experimental.Optional` that either contains the next element of an
  iterator if one exists, or an "empty" value that indicates the end of the
  sequence has been reached.
  
  `tf.experimental.Optional` can only be used with values that are convertible
  to `tf.Tensor` or `tf.CompositeTensor`.
  
  One can create a `tf.experimental.Optional` from a value using the
  `from_value()` method:
  
  >>> optional = tf.experimental.Optional.from_value(42)
  >>> print(optional.has_value())
  tf.Tensor(True, shape=(), dtype=bool)
  >>> print(optional.get_value())
  tf.Tensor(42, shape=(), dtype=int32)
  
  or without a value using the `empty()` method:
  
  >>> optional = tf.experimental.Optional.empty(
  ...   tf.TensorSpec(shape=(), dtype=tf.int32, name=None))
  >>> print(optional.has_value())
  tf.Tensor(False, shape=(), dtype=bool)
docstr: Returns a `tf.experimental.Optional` that wraps the given value.
  
  >>> optional = tf.experimental.Optional.from_value(42)
  >>> print(optional.has_value())
  tf.Tensor(True, shape=(), dtype=bool)
  >>> print(optional.get_value())
  tf.Tensor(42, shape=(), dtype=int32)
  
  Args:
    value: A value to wrap. The value must be convertible to `tf.Tensor` or
      `tf.CompositeTensor`.
  
  Returns:
    A `tf.experimental.Optional` that wraps `value`.
docstr_tok: ["Returns","a","`","tf.experimental.Optional","`","that","wraps","the","given","value",".",">",">",">","optional","=","tf.experimental.Optional.from_value","(","42",")",">",">",">","print","(","optional.has_value","(",")",")","tf.Tensor","(","True",",","shape=","(",")",",","dtype=bool",")",">",">",">","print","(","optional.get_value","(",")",")","tf.Tensor","(","42",",","shape=","(",")",",","dtype=int32",")","Args",":","value",":","A","value","to","wrap",".","The","value","must","be","convertible","to","`","tf.Tensor","`","or","`","tf.CompositeTensor","`",".","Returns",":","A","`","tf.experimental.Optional","`","that","wraps","`","value","`","."]
code: def from_value(value):
      """Returns a `tf.experimental.Optional` that wraps the given value.
  
      >>> optional = tf.experimental.Optional.from_value(42)
      >>> print(optional.has_value())
      tf.Tensor(True, shape=(), dtype=bool)
      >>> print(optional.get_value())
      tf.Tensor(42, shape=(), dtype=int32)
  
      Args:
        value: A value to wrap. The value must be convertible to `tf.Tensor` or
          `tf.CompositeTensor`.
  
      Returns:
        A `tf.experimental.Optional` that wraps `value`.
      """
      with ops.name_scope("optional") as scope:
          with ops.name_scope("value"):
              element_spec = structure.type_spec_from_value(value)
              encoded_value = structure.to_tensor_list(
                  element_spec, value
              )
  
      return _OptionalImpl(
          gen_optional_ops.optional_from_value(
              encoded_value, name=scope
          ),
          element_spec,
      )
  
imports: import abc
  from tensorflow.core.protobuf import struct_pb2
  from tensorflow.python.data.util import structure
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import type_spec
  from tensorflow.python.ops import gen_optional_ops
  from tensorflow.python.saved_model import nested_structure_coder
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 5 for calling the Optional obj's underlying member method code with example usage: obj.from_value(value) and returns: _OptionalImpl