def METHOD_NAME(msg):
    data = msg["content"]["data"]
    if data["type"] == FORMATTING_IMPORTS:
        msg_id = data.get("msg_id", None)
        imports = data.get("imports", None)
        fmt_code = _reformat_helper(data["input_code"], imports)
        comm.send(
            {
                "msg_id": msg_id,
                "formatted_code": str(fmt_code),
                "type": FORMATTING_IMPORTS,
            }
        )
    elif data["type"] == TIDY_IMPORTS:
        checksum = data.get("checksum", '')
        cell_array = data.get("cellArray", [])
        import_statements, processed_cell_array = [], []
        for cell in cell_array:
            text = cell.get("text")
            cell_type = cell.get("type")
            if cell_type == "code":
                imports, text = extract_import_statements(text)
                import_statements += imports
            processed_cell_array.append({"text": text, "type": cell_type})
        code_with_collected_imports = collect_code_with_imports_on_top(import_statements, processed_cell_array)
        code_post_tidy_imports = run_tidy_imports(code_with_collected_imports)
        import_statements, _ = extract_import_statements(code_post_tidy_imports)
        comm.send(
            {
                "checksum": checksum,
                "type": TIDY_IMPORTS,
                "cells": processed_cell_array,
                "imports": [im.strip() for im in import_statements],
            }
        )