human
Complete this python program:
def generate_import_code(pipeline, operators):
assistant
#Here is the Python program you requested.

    """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
    Returns
    pipeline_text: String
    The Python program that imports all required library used in the current
    optimized pipeline
    """
    def merge_imports(old_dict, new_dict):
        for key in new_dict.keys():
            if (key in old_dict.keys()):
                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\n\n'
    pipeline_imports = _starting_imports(operators, operators_used)
    import_relations = {op.__name__: op.import_hash for op in operators}
    for op in operators_used:
        try:
            operator_import = import_relations[op]
            merge_imports(pipeline_imports, operator_import)
        except KeyError:
            pass
    for key in sorted(pipeline_imports.keys()):
        module_list = ',    '.join(sorted(pipeline_imports[key]))
        pipeline_text += 'from    {}    import    {}\n'.format(key, module_list)
    return pipeline_text