code: def __extract_imports(func):
      def add_import_guard(import_):
          return (
              "try:\n    "
              + import_.replace("\n", "\n    ", import_.count("\n") - 1)
              + "\nexcept Exception as e:\n    print('Import error: ' + str(e))\n"
          )
  
      # noinspection PyBroadException
      try:
          import ast
  
          func_module = inspect.getmodule(func)
          source = inspect.getsource(func_module)
          parsed_source = ast.parse(source)
          imports = []
          for parsed_source_entry in parsed_source.body:
              # we only include global imports (i.e. at col_offset 0)
              if parsed_source_entry.col_offset != 0:
                  continue
              if isinstance(parsed_source_entry, ast.ImportFrom):
                  for sub_entry in parsed_source_entry.names:
                      import_str = "from {} import {}".format(
                          parsed_source_entry.module, sub_entry.name
                      )
                      if sub_entry.asname:
                          import_str += " as {}".format(
                              sub_entry.asname
                          )
                      imports.append(import_str)
              elif isinstance(parsed_source_entry, ast.Import):
                  for sub_entry in parsed_source_entry.names:
                      import_str = "import {}".format(sub_entry.name)
                      if sub_entry.asname:
                          import_str += " as {}".format(
                              sub_entry.asname
                          )
                      imports.append(import_str)
          imports = [add_import_guard(import_) for import_ in imports]
          return "\n".join(imports)
      except Exception as e:
          getLogger().warning(
              "Could not fetch function imports: {}".format(e)
          )
          return ""
  
imports: import inspect
  import json
  import os
  import re
  import tempfile
  from sys import platform
  from functools import reduce
  from logging import getLogger
  from typing import Optional, Sequence, Union, Tuple, List, Callable, Dict, Any
  from pathlib2 import Path
  from six.moves.urllib.parse import urlparse
  from .args import _Arguments
  from .repo import ScriptInfo
  from ...task import Task
label_desc: Use image node_id 3 for calling the CreateFromFunction obj's underlying member method code with example usage: obj.__extract_imports(func) and returns: unknown, str, str