code: def import_obj(clsname, default_module=None):
      """
      Import the object given by clsname.
      If default_module is specified, import from this module.
      """
      if default_module is not None:
          if not clsname.startswith(default_module + "."):
              clsname = "{0}.{1}".format(default_module, clsname)
      mod, clsname = clsname.rsplit(".", 1)
      mod = importlib.import_module(mod)
      try:
          obj = getattr(mod, clsname)
      except AttributeError:
          raise ImportError(
              "Cannot import {0} from {1}".format(clsname, mod)
          )
      return obj
  
file_path: pdvega/doc/sphinxext/pdvega_ext/utils.py
imports: import ast
  import json
  import importlib
  from hashlib import md5
  from itertools import tee, chain
label_desc: Use image node_id 3 for calling a global function with example usage: import_obj(clsname, default_module) and returns: obj