code: def extract_imports(source, verbose=True):
      tree = ast.parse(source)
      import_parser = ImportParser()
      import_parser.visit(tree)
      import_lines = ["#coding=utf-8\n"]
      for line in import_parser.lines:
          if "print_function" in line:
              import_lines.append(line + "\n")
          # skip imports for pycharm and eclipse
          elif "_pydev_" in line or "java.lang" in line:
              continue
          else:
              import_lines.append(
                  "try:\n    {}\nexcept:\n    pass\n".format(line)
              )
      imports_str = "\n".join(import_lines)
      if verbose:
          print(">>> Imports:")
          print(imports_str)
      return imports_str
  
imports: import ast
  import re
  import warnings
  from operator import attrgetter
  from hyperopt import space_eval
label_desc: Use image node_id 1 for calling a global function with example usage: extract_imports(source, verbose) and returns: imports_str