code: def check_or_get_class(
      class_or_name, module_path=None, superclass=None
  ):
      """Returns the class and checks if the class inherits :attr:`superclass`.
  
      Args:
          class_or_name: Name or full path to the class, or the class itself.
          module_paths (list, optional): Paths to candidate modules to search
              for the class. This is used if :attr:`class_or_name` is a string and
              the class cannot be located solely based on :attr:`class_or_name`.
              The first module in the list that contains the class
              is used.
          superclass (optional): A (list of) classes that the target class
              must inherit.
  
      Returns:
          The target class.
  
      Raises:
          ValueError: If class is not found based on :attr:`class_or_name` and
              :attr:`module_paths`.
          TypeError: If class does not inherits :attr:`superclass`.
      """
      class_ = class_or_name
      if is_str(class_):
          class_ = get_class(class_, module_path)
      if superclass is not None:
          if not issubclass(class_, superclass):
              raise TypeError(
                  "A subclass of {} is expected. Got: {}".format(
                      superclass, class_
                  )
              )
      return class_
  
imports: from typing import List, Union
  import inspect
  import funcsigs
  from pydoc import locate
  import copy
  import collections
  import numpy
  import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.utils.dtypes import is_str, is_callable, compat_as_text, _maybe_list_to_array
label_desc: Use image node_id 5 for calling a global function with example usage: check_or_get_class(class_or_name, module_path, superclass) and returns: class_