@staticmethod
  def merge(co_source, co_input, location=UNKNOWN, \
            ins_lineno=-1, ins_offset=-1, ins_import_names=None):
    if not co_input:
      raise Exception('Input code_object is None')

    new_co = CodeObject(co_source)
    new_co.merge_fields(co_input)
    new_co.reset_code()

    bc_source = BytecodeObject.get_parsed_code(co_source)
    bc_input = BytecodeObject.get_parsed_code(co_input)[:-2]

    # logger.debug("ins_import_names := %s", ins_import_names)

    if ins_import_names:
      for name in ins_import_names:
        # logger.debug("Adding global name: %s", name)
        new_co.add_global_name(name)

    # logger.debug("Enter code_object:\n" + get_debug_code_object_info(co_input))
    # logger.debug("Instrument bytecode:\n%s", show_bytecode(bc_input))

    new_bytecode = None
    if location == Merger.MODULE_EXIT:
      new_bytecode = Merger.merge_exit(new_co, bc_source, bc_input, ins_import_names)
    else:

      if Merger.already_instrumented(bc_source, bc_input):
        logger.debug("Already instrumented code object. Skipping")
        return

      # list [(bc elements), instrument_code frame counter)]
      bytecode = Merger.get_final_bytecode(bc_source, bc_input,
                                           co_source, co_input,
                                           location,
                                           ins_lineno, ins_offset)

      new_bytecode = Merger.resolve_jump_targets(bytecode, new_co)

    for bc_tpl in new_bytecode:
      new_co.append(bc_tpl[0][2], bc_tpl[0][3], bc_tpl[0][0], bc_tpl[0][1])

    final_new_co = new_co.to_code()

    # logger.debug("New code_object:\n" + get_debug_code_object_info(final_new_co))
    # final_bc = BytecodeObject.get_parsed_code(final_new_co)
    # logger.debug("New bytecode:\n" + show_bytecode(final_bc))

    return final_new_co
The merger makes sure that the bytecode is properly inserted where
dataset/ETHPy150Open neuroo/equip/equip/rewriter/merger.py/Merger.merge