code: def workon(
      function: Callable,
      space: dict,
      name: str = "loop",
      algorithm: type[BaseAlgorithm] | str | dict | None = None,
      algorithms: type[BaseAlgorithm] | str | dict | None = None,
      max_trials: int | None = None,
      max_broken: int | None = None,
      knowledge_base: KnowledgeBase | None = None,
  ):
      """Optimize a function over a given search space
  
      This will create a new experiment with an in-memory storage and optimize the given function
      until `max_trials` is reached or the `algorithm` is done
      (some algorithm like random search are never done).
  
      For information on how to fetch results, see
      :py:class:`orion.client.experiment.ExperimentClient`.
  
      .. note::
  
          Each call to this function will create a separate in-memory storage.
  
      Parameters
      ----------
      name: str
          Name of the experiment
      version: int, optional
          Version of the experiment. Defaults to last existing version for a given `name`
          or 1 for new experiment.
      space: dict, optional
          Optimization space of the algorithm. Should have the form `dict(name='<prior>(args)')`.
      algorithm: str or dict, optional
          Algorithm used for optimization.
      max_trials: int, optional
          Maximum number or trials before the experiment is considered done.
      max_broken: int, optional
          Number of broken trials for the experiment to be considered broken.
  
      Raises
      ------
      `NotImplementedError`
          If the algorithm specified is not properly installed.
  
      """
      experiment = experiment_builder.build(
          name,
          version=1,
          space=space,
          algorithm=algorithm,
          algorithms=algorithms,
          max_trials=max_trials,
          max_broken=max_broken,
          storage={
              "type": "legacy",
              "database": {"type": "EphemeralDB"},
          },
          knowledge_base=knowledge_base,
      )
  
      experiment_client = ExperimentClient(experiment)
  
      with experiment_client.tmp_executor(
          "singleexecutor", n_workers=1
      ):
          experiment_client.workon(
              function, n_workers=1, max_trials=max_trials
          )
  
      return experiment_client
  
file_path: orion/src/orion/client/__init__.py
imports: from __future__ import annotations
  import logging
  import typing
  from typing import Any, Callable
  import orion.core.io.experiment_builder
  from orion.algo.base import BaseAlgorithm
  from orion.client.cli import interrupt_trial, report_bad_trial, report_objective, report_results
  from orion.client.experiment import ExperimentClient
  from orion.core.utils.exceptions import RaceCondition
  from orion.core.worker.producer import Producer
  from orion.core.worker.warm_start.knowledge_base import KnowledgeBase
  from orion.executor.base import BaseExecutor
  from orion.storage.base import BaseStorageProtocol, setup_storage
label_desc: Use image node_id 4 for calling a global function with example usage: workon(function, space, name, algorithm, algorithms, max_trials, max_broken, knowledge_base) and returns: experiment_client