code: def _instantiate_knowledge_base(
      kb_config: dict[str, Any]
  ) -> KnowledgeBase:
      """Instantiate the Knowledge base from its configuration."""
      if len(kb_config) != 1:
          raise ConfigurationError(
              f"The configuration for the KB should only have one key (the name of the KB "
              f"class) and the dict of kwargs. (got {kb_config})"
          )
      kb_type_name = list(kb_config.keys())[0]
      kb_types_with_name = [
          subclass
          for subclass in (
              KnowledgeBase.__subclasses__() + [KnowledgeBase]
          )
          if subclass.__name__ == kb_type_name
      ]
      if len(kb_types_with_name) == 0:
          raise ConfigurationError(
              f"Unable to find a subclass of KnowledgeBase with the given name: {kb_type_name}"
          )
      if len(kb_types_with_name) > 1:
          raise ConfigurationError(
              f"Multiple subclasses of KnowledgeBase with the given name: {kb_type_name}"
          )
      kb_type = kb_types_with_name[0]
      kb_kwargs = kb_config[kb_type_name]
      # Instantiate the storage that is required for the KB.
      storage_config = kb_kwargs["storage"]
      if isinstance(storage_config, dict):
          storage = setup_storage(storage_config)
          kb_kwargs["storage"] = storage
      return kb_type(**kb_kwargs)
  
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 6 for calling a global function with example usage: _instantiate_knowledge_base(kb_config) and returns: kb_type