code: def extracted_tasks_to_tune_contexts(
      extracted_tasks: List[ExtractedTask],
      work_dir: str,
      space: SpaceGenerator.SpaceGeneratorType = "post-order-apply",
      strategy: SearchStrategy.SearchStrategyType = "evolutionary",
      num_tuning_cores: Union[
          Literal["physical", "logical"], int
      ] = "physical",
      seed: Optional[int] = None,
  ) -> Tuple[List[TuneContext], List[float]]:
      """Convert ExtractedTask to TuneContext.
  
      Parameters
      ----------
      tasks : List[ExtractedTask]
          The tasks to be converted
      work_dir : str
          The working directory to store logs and databases
      space : SpaceGenerator.SpaceGeneratorType
          The space generator to use.
      strategy : SearchStrategy.SearchStrategyType
          The search strategy to use.
      num_tuning_cores : Union[Literal["physical", "logical"], int]
          The number of CPU cores to use during tuning.
      seed : Optional[int]
          The random seed to use.
  
      Returns
      -------
      tasks : List[TuneContext]
          The converted tasks
      task_weights : List[float]
          The weights of the tasks
      """
      tasks: List[TuneContext] = []
      task_weights: List[float] = []
      for task, logger, rand_state in zip(
          extracted_tasks,
          get_loggers_from_work_dir(
              work_dir, [t.task_name for t in extracted_tasks]
          ),
          fork_seed(seed, n=len(extracted_tasks)),
      ):
          tasks.append(
              TuneContext(
                  mod=task.dispatched[0],
                  target=task.target,
                  space_generator=space,
                  search_strategy=strategy,
                  task_name=task.task_name,
                  logger=logger,
                  rand_state=rand_state,
                  num_threads=num_tuning_cores,
              ).clone()
          )
          task_weights.append(task.weight)
      return tasks, task_weights
  
imports: from contextlib import contextmanager
  from types import MappingProxyType
  from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Sequence, Set, Tuple, Union
  from typing_extensions import Literal
  import numpy
  from tvm import nd
  from tvm._ffi import get_global_func
  from tvm.ir import IRModule, transform
  from tvm.ir.instrument import PassInstrument
  from tvm.runtime import NDArray
  from tvm.target import Target
  from .builder import Builder
  from .cost_model import CostModel
  from .database import Database
  from .extracted_task import ExtractedTask
  from .logging import get_loggers_from_work_dir
  from .measure_callback import MeasureCallback
  from .profiler import Profiler
  from .runner import Runner
  from .search_strategy import SearchStrategy
  from .space_generator import SpaceGenerator
  from .task_scheduler import TaskScheduler
  from .tune import tune_tasks
  from .tune_context import TuneContext
  from .utils import fork_seed
label_desc: Use image node_id 4 for calling a global function with example usage: extracted_tasks_to_tune_contexts(extracted_tasks, work_dir, space, strategy, num_tuning_cores, seed) and returns: tasks,  task_weights