code: def remove_optional(annotation):
      """
      Optional[X] annotations are actually represented as Union[X, NoneType].
      For our purposes, the "Optional" part is not interesting, so here we
      throw it away.
      """
      origin = getattr(annotation, "__origin__", None)
      args = getattr(annotation, "__args__", ())
      if origin == Union and len(args) == 2 and args[1] == type(None):
          return args[0]
      else:
          return annotation
  
file_path: magnitude/pymagnitude/third_party/allennlp/common/from_params.py
imports: from __future__ import absolute_import
  from __future__ import print_function
  import inspect
  import logging
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.params import Params
label_desc: Use image node_id 2 for calling a global function with example usage: remove_optional(annotation) and returns: args, annotation