optional_get_element#

ivy.optional_get_element(x=None, /, *, out=None)[source]#

If the input is a tensor or sequence type, it returns the input. If the input is an optional type, it outputs the element in the input. It is an error if the input is an empty optional-type (i.e. does not have an element) and the behavior is undefined in this case.

Parameters:
  • x (Optional[Array], default: None) – Input array

  • out (Optional[Array], default: None) – Optional output array, for writing the result to.

Return type:

Array

Returns:

ret – Input array if it is not None

Array.optional_get_element(self=None, /, *, out=None)[source]#

If the input is a tensor or sequence type, it returns the input. If the input is an optional type, it outputs the element in the input. It is an error if the input is an empty optional-type (i.e. does not have an element) and the behavior is undefined in this case.

Parameters:
  • self (Optional[Array], default: None) – Input array

  • out (Optional[Array], default: None) – Optional output array, for writing the result to.

Return type:

Array

Returns:

ret – Input array if it is not None

Container.optional_get_element(self, /, *, out=None)[source]#

ivy.Container instance method variant of ivy.optional_get_element. This method simply wraps the function, and so the docstring for ivy.optional_get_element also applies to this method with minimal changes.

Parameters:
  • self (Container) – Input container

  • out (Optional[Container], default: None) – Optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Output container.