code: def _instantiate_algo(
      space: Space,
      max_trials: int | None,
      config: type[BaseAlgorithm] | str | dict | None = None,
      ignore_unavailable: bool = False,
      knowledge_base: KnowledgeBase | None = None,
  ):
      """Instantiate the algorithm object
  
      Parameters
      ----------
      config:
          Configuration of the algorithm. If None or empty, system's defaults are used
          (orion.core.config.experiment.algorithm).
      ignore_unavailable: bool, optional
          If True and algorithm is not available (plugin not installed), return the configuration.
          Otherwise, raise Factory error.
  
      """
      config = config or orion.core.config.experiment.algorithm
      assert config is not None
      try:
          algo_type: type[BaseAlgorithm]
          algo_config: dict
          if isinstance(config, str):
              algo_type = algo_factory.get_class(config)
              algo_config = {}
          elif isinstance(config, dict):
              backported_config = backward.port_algo_config(config)
              algo_name = backported_config.pop("of_type")
              algo_type = algo_factory.get_class(algo_name)
              algo_config = backported_config
          else:
              assert issubclass(config, BaseAlgorithm)
              algo_type = config
              algo_config = {}
  
          wrapped_algo = create_algo(
              space=space,
              algo_type=algo_type,
              knowledge_base=knowledge_base,
              **algo_config,
          )
          if max_trials is not None:
              wrapped_algo.max_trials = max_trials
  
      except NotImplementedError as e:
          if not ignore_unavailable:
              raise e
          log.warning(str(e))
          log.warning("Algorithm will not be instantiated.")
          wrapped_algo = config
  
      return wrapped_algo
  
imports: from __future__ import annotations
  import copy
  import datetime
  import getpass
  import logging
  import pprint
  import sys
  import typing
  from typing import Any, TypeVar
  import orion.core
  from orion.algo.base import BaseAlgorithm, algo_factory
  from orion.algo.space import Space
  from orion.core.evc.adapters import BaseAdapter
  from orion.core.evc.conflicts import ExperimentNameConflict, detect_conflicts
  from orion.core.io import resolve_config
  from orion.core.io.config import ConfigurationError
  from orion.core.io.database import DuplicateKeyError
  from orion.core.io.experiment_branch_builder import ExperimentBranchBuilder
  from orion.core.io.interactive_commands.branching_prompt import BranchingPrompt
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.utils import backward
  from orion.core.utils.exceptions import BranchingEvent, NoConfigurationError, NoNameError, RaceCondition
  from orion.core.worker.experiment import Experiment, Mode
  from orion.core.worker.experiment_config import ExperimentConfig
  from orion.core.worker.primary_algo import create_algo
  from orion.core.worker.warm_start import KnowledgeBase
  from orion.storage.base import setup_storage
label_desc: Use image node_id 7 for calling a global function with example usage: _instantiate_algo(space, max_trials, config, ignore_unavailable, knowledge_base) and returns: wrapped_algo