Convert `obj` to a graph element if possible, otherwise return `None`. Args: obj: Object to convert. Returns: The result of `obj._as_graph_element()` if that method is available; otherwise `None`.
(obj)
| 181 | |
| 182 | |
| 183 | def _as_graph_element(obj): |
| 184 | """Convert `obj` to a graph element if possible, otherwise return `None`. |
| 185 | |
| 186 | Args: |
| 187 | obj: Object to convert. |
| 188 | |
| 189 | Returns: |
| 190 | The result of `obj._as_graph_element()` if that method is available; |
| 191 | otherwise `None`. |
| 192 | """ |
| 193 | conv_fn = getattr(obj, "_as_graph_element", None) |
| 194 | if conv_fn and callable(conv_fn): |
| 195 | return conv_fn() |
| 196 | return None |
| 197 | |
| 198 | |
| 199 | _TENSOR_LIKE_TYPES = tuple() |
no outgoing calls
no test coverage detected