code: def _assert_valid_type_signature(type_sig, type_sig_name):
      """Checks that the given type signature is valid.
  
      Valid type signatures are either a single Python class, or a dictionary
      mapping string names to Python classes.
  
      Throws a well formatted exception when invalid.
  
      Args:
        type_sig: Type signature to validate.
        type_sig_name: Variable name of the type signature. This is used in
            exception descriptions.
  
      Raises:
        InvalidTypeSignatureError: If `type_sig` is not valid.
      """
      if isinstance(type_sig, dict):
          for k, val in type_sig.items():
              if not isinstance(k, six.string_types):
                  raise InvalidTypeSignatureError(
                      "%s key %s must be a string." % (type_sig_name, k)
                  )
              if not inspect.isclass(val):
                  raise InvalidTypeSignatureError(
                      "%s %s at key %s must be a Python class."
                      % (type_sig_name, val, k)
                  )
      else:
          if not inspect.isclass(type_sig):
              raise InvalidTypeSignatureError(
                  "%s %s must be a Python class."
                  % (type_sig_name, type_sig)
              )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import inspect
  import os.path
  from magenta.pipelines import statistics
  import six
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: _assert_valid_type_signature(type_sig, type_sig_name) without return types