code: def is_defined_by_module(item, module, parent=None):
      flag = False
      if isinstance(item, types.ModuleType):
          if not hasattr(item, '__file__'):
              try:
                  import utool as ut
                  name = ut.get_modname_from_modpath(module.__file__)
                  flag = name in str(item)
              except:
                  flag = False
          else:
              item_modpath = os.path.realpath(dirname(item.__file__))
              mod_fpath = module.__file__.replace('.pyc', '.py')
              if not mod_fpath.endswith('__init__.py'):
                  flag = False
              else:
                  modpath = os.path.realpath(dirname(mod_fpath))
                  modpath = modpath.replace('.pyc', '.py')
                  flag = item_modpath.startswith(modpath)
      elif hasattr(item, '_utinfo'):
          orig_func = item._utinfo['orig_func']
          flag = is_defined_by_module(orig_func, module, parent)
      else:
          if isinstance(item, staticmethod):
              item = item.__func__
          try:
              func_globals = meta_util_six.get_funcglobals(item)
              func_module_name = func_globals['__name__']
              if func_module_name == 'line_profiler':
                  valid_names = dir(module)
                  if parent is not None:
                      valid_names += dir(parent)
                  if item.func_name in valid_names:
                      if len(item.func_name) > 6:
                          flag = True
              elif func_module_name == module.__name__:
                  flag = True
          except  AttributeError:
              if hasattr(item, '__module__'):
                  flag = item.__module__ == module.__name__
      return flag