code: def test_handle_cursor_early_cancel(
      engine_mock: Mock,
      cancel_query_mock: Mock,
      cancel_early: bool,
      mocker: MockerFixture,
  ) -> None:
      from superset.db_engine_specs.trino import TrinoEngineSpec
      from superset.models.sql_lab import Query
  
      query_id = "myQueryId"
  
      cursor_mock = engine_mock.return_value.__enter__.return_value
      cursor_mock.query_id = query_id
  
      query = Query()
  
      if cancel_early:
          TrinoEngineSpec.prepare_cancel_query(query=query)
  
      TrinoEngineSpec.handle_cursor(cursor=cursor_mock, query=query)
  
      if cancel_early:
          assert (
              cancel_query_mock.call_args[1]["cancel_query_id"]
              == query_id
          )
      else:
          assert cancel_query_mock.call_args is None
  
imports: import copy
  import json
  from datetime import datetime
  from typing import Any, Optional
  from unittest.mock import Mock, patch
  import pandas
  import pytest
  from pytest_mock import MockerFixture
  from sqlalchemy import types
  from trino.sqlalchemy import datatype
  import superset.config
  from superset.constants import QUERY_CANCEL_KEY, QUERY_EARLY_CANCEL_KEY, USER_AGENT
  from superset.superset_typing import ResultSetColumnType, SQLAColumnType
  from superset.utils.core import GenericDataType
  from tests.unit_tests.db_engine_specs.utils import assert_column_spec, assert_convert_dttm
  from tests.unit_tests.fixtures.common import dttm
label_desc: Use image node_id 16 for calling a global function with example usage: test_handle_cursor_early_cancel(engine_mock, cancel_query_mock, cancel_early, mocker) without return types