code: def optional(converter):
      """
      A converter that allows an attribute to be optional. An optional attribute
      is one which can be set to ``None``.
  
      Type annotations will be inferred from the wrapped converter's, if it
      has any.
  
      :param callable converter: the converter that is used for non-``None``
          values.
  
      .. versionadded:: 17.1.0
      """
  
      def optional_converter(val):
          if val is None:
              return None
          return converter(val)
  
      if not PY2:
          sig = None
          try:
              sig = inspect.signature(converter)
          except (ValueError, TypeError):  # inspect failed
              pass
          if sig:
              params = list(sig.parameters.values())
              if (
                  params
                  and params[0].annotation
                  is not inspect.Parameter.empty
              ):
                  optional_converter.__annotations__[
                      "val"
                  ] = typing.Optional[params[0].annotation]
              if sig.return_annotation is not inspect.Signature.empty:
                  optional_converter.__annotations__[
                      "return"
                  ] = typing.Optional[sig.return_annotation]
  
      return optional_converter
  
imports: from __future__ import absolute_import, division, print_function
  from ._compat import PY2
  from ._make import NOTHING, Factory, pipe
label_desc: Use image node_id 1 for calling a global function with example usage: optional(converter) and returns: optional_converter, converter, None