class_docstr: Tests for the multi-task wrapper.
class_docstr_tok: ["Tests","for","the","multi-task","wrapper","."]
docstr: Test that when an algo is wrapped with the multi-task wrapper, the trials it returns
  with suggest() have an additional 'task-id' value.
code: def test_adds_task_id(self, knowledge_base: KnowledgeBase):
      """Test that when an algo is wrapped with the multi-task wrapper, the trials it returns
      with suggest() have an additional 'task-id' value.
      """
      algo_type = Random
      max_trials = 10
      experiment = build_experiment(
          name="target_1",
          space=target_space,
          knowledge_base=knowledge_base,
          algorithm=algo_type,
          max_trials=max_trials,
          debug=True,
      )
      # NOTE: There's a deepcopy happening in the build_experiment function, so this isn't true:
      # assert experiment._experiment.knowledge_base is knowledge_base
      # However we can check that the knowledge_base is indeed being set:
      assert isinstance(
          experiment._experiment.knowledge_base, KnowledgeBase
      )
  
      # IDEA: Add type hints to the `Experiment` class, and make it generic in terms of the
      # algorithms, so that we could get the `algorithms` to be algo_type here.
      algo = experiment.algorithm
      assert isinstance(algo, MultiTaskWrapper)
      assert isinstance(algo.unwrapped, algo_type)
      assert experiment.fetch_trials() == []
      assert not experiment.is_done
  
      trial = algo.suggest(1)[0]
      assert len(algo.registry) == 1
      assert list(algo.registry) == [trial]
      # There may be more than one trial which map to this one.
      assert len(algo.unwrapped.registry) >= 1
      assert all(
          "task_id" in trial.params for trial in algo.unwrapped.registry
      )
  
      trial_with_result = _add_result(trial, 0)
      algo.observe([trial_with_result])
      assert all(
          "task_id" in trial.params for trial in algo.unwrapped.registry
      )
  
imports: from __future__ import annotations
  import copy
  import random
  from typing import Any, Callable, Sequence
  import numpy
  import pytest
  from orion.algo.base import BaseAlgorithm
  from orion.algo.gridsearch import GridSearch
  from orion.algo.space import Space
  from orion.algo.tpe import TPE
  from orion.client import build_experiment
  from orion.client.experiment import ExperimentClient
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.worker.algo_wrappers.insist_suggest import InsistSuggest
  from orion.core.worker.algo_wrappers.space_transform import SpaceTransform
  from orion.core.worker.experiment import Experiment
  from orion.core.worker.experiment_config import ExperimentConfig
  from orion.core.worker.primary_algo import create_algo
  from orion.core.worker.trial import Trial
  from orion.core.worker.warm_start.knowledge_base import KnowledgeBase
  from orion.core.worker.warm_start.multi_task_wrapper import MultiTaskWrapper
  from orion.storage.base import BaseStorageProtocol
  from orion.testing.dummy_algo import FixedSuggestionAlgo
  from orion.algo.random import Random
  from orion.core.worker.warm_start import WarmStarteable
label_desc: Use image node_id 3 for calling the TestMultiTaskWrapper obj's underlying member method code with example usage: obj.test_adds_task_id(knowledge_base) without return types