Returns an `Optional` that wraps the given value. Args: value: A value to wrap. The value must be convertible to `Tensor` or `CompositeTensor`. Returns: An `Optional` that wraps `value`.
(value)
| 86 | |
| 87 | @staticmethod |
| 88 | def from_value(value): |
| 89 | """Returns an `Optional` that wraps the given value. |
| 90 | |
| 91 | Args: |
| 92 | value: A value to wrap. The value must be convertible to `Tensor` or |
| 93 | `CompositeTensor`. |
| 94 | |
| 95 | Returns: |
| 96 | An `Optional` that wraps `value`. |
| 97 | """ |
| 98 | with ops.name_scope("optional") as scope: |
| 99 | with ops.name_scope("value"): |
| 100 | value_structure = structure.type_spec_from_value(value) |
| 101 | encoded_value = structure.to_tensor_list(value_structure, value) |
| 102 | |
| 103 | return _OptionalImpl( |
| 104 | gen_dataset_ops.optional_from_value(encoded_value, name=scope), |
| 105 | value_structure) |
| 106 | |
| 107 | @staticmethod |
| 108 | def none_from_structure(value_structure): |