code: def is_std_or_local_lib(name):
      """Check whether it is stdlib module.
      True if std lib
      False if installed package
      str if local library
      """
  
      # check if one of the builtin modules first
      if name in sys.builtin_module_names:
          return True
  
      exist = True
      if six.PY2:
          import imp  # noqa
          from types import FileType  # noqa
  
          module_info = ("", "", "")
          try:
              module_info = imp.find_module(name)
          except ImportError:
              try:
                  # __import__(name)
                  importlib.import_module(name)
                  module_info = imp.find_module(name)
                  sys.modules.pop(name)
              except ImportError:
                  exist = False
          # Testcase: ResourceWarning
          if isinstance(module_info[0], FileType):
              module_info[0].close()  # noqa
          mpath = module_info[1]  # noqa
          # make sure we remove built-in modules
          if mpath and not os.path.exists(mpath):
              mpath = None
      else:
          module_info = None
          try:
              module_info = importlib.util.find_spec(name)  # noqa
          except ImportError:
              return False
          except ValueError:
              # if we got here, the loader failed on us, meaning this is definitely a module and not std
              return False
          if not module_info:
              if name == "__builtin__":
                  return True
              return False
          mpath = module_info.origin
          # this is a subpackage
          if not mpath and module_info.loader is not None:
              return False
          # this is std
          if mpath == "built-in":
              mpath = None
  
      if exist and mpath is not None:
          if (
              "site-packages" in mpath
              or "dist-packages" in mpath
              or "bin/" in mpath
              and mpath.endswith(".py")
          ):
              exist = False
          elif (
              (sys.prefix not in mpath)
              and (six.PY2 or (sys.base_exec_prefix not in mpath))
              and (six.PY2 or (sys.base_prefix not in mpath))
          ):
              exist = mpath
  
      return exist
  
imports: from __future__ import print_function, division, absolute_import
  import json
  import os
  import sys
  import six
  import fnmatch
  import importlib
  import ast
  import doctest
  import collections
  import functools
  from pathlib2 import Path
  from .utils import parse_git_config
  from .modules import ImportedModules
label_desc: Use image node_id 4 for calling a global function with example usage: is_std_or_local_lib(name) and returns: exist, True, False, False, False, False, True