code: def OrionState(*args, **kwargs):
      """Build an orion state in function of the storage type"""
      storage = kwargs.get("storage")
  
      if not storage or storage["type"] == "legacy":
          return LegacyOrionState(*args, **kwargs)
  
      return BaseOrionState(*args, **kwargs)
  
imports: import copy
  import os
  import tempfile
  import yaml
  import orion
  from orion.core.io import experiment_builder
  from orion.core.worker.trial import Trial
  from orion.storage.base import setup_storage, storage_factory
label_desc: Use image node_id 1 for calling a global function with example usage: OrionState() and returns: BaseOrionState, LegacyOrionState