code: def generate_import_code(
      pipeline, operators, impute=False, random_state=None
  ):
      """Generate all library import calls for use in TPOT.export().
  
      Parameters
      ----------
      pipeline: List
          List of operators in the current optimized pipeline
      operators:
          List of operator class from operator library
      impute : bool
          Whether to impute new values in the feature set.
      random_state: integer or None
          Random seed in train_test_split function and exported pipeline.
  
      Returns
      -------
      pipeline_text: String
          The Python code that imports all required library used in the current
          optimized pipeline
  
      """
  
      def merge_imports(old_dict, new_dict):
          # Key is a module name
          for key in new_dict.keys():
              if key in old_dict.keys():
                  # Union imports from the same module
                  old_dict[key] = set(old_dict[key]) | set(
                      new_dict[key]
                  )
              else:
                  old_dict[key] = set(new_dict[key])
  
      operators_used = [
          x.name for x in pipeline if isinstance(x, deap.gp.Primitive)
      ]
      pipeline_text = "import numpy as np\nimport pandas as pd\n"
  
      # Build dict of import requirments from list of operators
      import_relations = {
          op.__name__: op.import_hash for op in operators
      }
  
      flatten_list = lambda list_: [
          item for sublist in list_ for item in sublist
      ]
      modules_used = [
          module.split(".")[0]
          for module in flatten_list(
              [list(val.keys()) for val in import_relations.values()]
          )
      ]
  
      if "imblearn" in modules_used:
          pipeline_module = "imblearn"
      else:
          pipeline_module = "sklearn"
  
      pipeline_imports = _starting_imports(
          operators, operators_used, pipeline_module
      )
  
      # Build import dict from used
      for op in operators_used:
          try:
              operator_import = import_relations[op]
              merge_imports(pipeline_imports, operator_import)
          except KeyError:
              pass  # Operator does not require imports
  
      # Build import string
      for key in sorted(pipeline_imports.keys()):
          module_list = ", ".join(sorted(pipeline_imports[key]))
          pipeline_text += "from {} import {}\n".format(
              key, module_list
          )
  
      # Add the imblearn pipeline if necessary
      if pipeline_module == "imblearn":
          pipeline_text += """from imblearn.pipeline import make_pipeline
  """
  
      # Add the imputer if necessary
      if impute:
          pipeline_text += """from sklearn.impute import SimpleImputer
  """
      if (
          random_state is not None
          and "sklearn.pipeline" in pipeline_imports
      ):
          pipeline_text += """from tpot.export_utils import set_param_recursive
  """
  
      return pipeline_text
  
file_path: tpot/tpot/export_utils.py
imports: import deap
label_desc: Use image node_id 4 for calling a global function with example usage: generate_import_code(pipeline, operators, impute, random_state) and returns: pipeline_text