code: def _fetch_config_version(
      configs: list[ExperimentConfig], version: int | None = None
  ) -> ExperimentConfig:
      """Fetch the experiment configuration corresponding to the given version
  
      Parameters
      ----------
      configs: list
          List of configurations fetched from storoge.
      version: int, optional
          Version to select. If None, last version will be selected. If version given is larger than
          largest version available, the largest version will be selected.
  
      """
      max_version = max(
          configs, key=lambda exp: exp.get("version", 1)
      ).get("version", 1)
  
      if version is None:
          version = max_version
      else:
          version = version
  
      if version > max_version:
          log.warning(
              "Version %s was specified but most recent version is only %s. Using %s.",
              version,
              max_version,
              max_version,
          )
  
      version = min(version, max_version)
  
      filtered_configs = filter(
          lambda exp: exp.get("version", 1) == version, configs
      )
  
      return next(iter(filtered_configs))
  
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 9 for calling a global function with example usage: _fetch_config_version(configs, version) and returns: next