code: def get_solver_from_xp(
      xp: XP,
      override_cfg: tp.Optional[
          tp.Union[dict, omegaconf.DictConfig]
      ] = None,
      restore: bool = True,
      load_best: bool = True,
      ignore_state_keys: tp.List[str] = [],
      disable_fsdp: bool = True,
  ):
      """Given a XP, return the Solver object.
  
      Args:
          xp (XP): Dora experiment for which to retrieve the solver.
          override_cfg (dict or None): If not None, should be a dict used to
              override some values in the config of `xp`. This will not impact
              the XP signature or folder. The format is different
              than the one used in Dora grids, nested keys should actually be nested dicts,
              not flattened, e.g. `{'optim': {'batch_size': 32}}`.
          restore (bool): If `True` (the default), restore state from the last checkpoint.
          load_best (bool): If `True` (the default), load the best state from the checkpoint.
          ignore_state_keys (list[str]): List of sources to ignore when loading the state, e.g. `optimizer`.
          disable_fsdp (bool): if True, disables FSDP entirely. This will
              also automatically skip loading the EMA. For solver specific
              state sources, like the optimizer, you might want to
              use along `ignore_state_keys=['optimizer']`. Must be used with `load_best=True`.
      """
      logger.info(
          f"Loading solver from XP {xp.sig}. "
          f"Overrides used: {xp.argv}"
      )
      cfg = xp.cfg
      if override_cfg is not None:
          cfg = omegaconf.OmegaConf.merge(
              cfg, omegaconf.DictConfig(override_cfg)
          )
      if disable_fsdp and cfg.fsdp.use:
          cfg.fsdp.use = False
          assert load_best is True
          # ignoring some keys that were FSDP sharded like model, ema, and best_state.
          # fsdp_best_state will be used in that case. When using a specific solver,
          # one is responsible for adding the relevant keys, e.g. 'optimizer'.
          # We could make something to automatically register those inside the solver, but that
          # seem overkill at this point.
          ignore_state_keys = ignore_state_keys + [
              "model",
              "ema",
              "best_state",
          ]
  
      try:
          with xp.enter():
              solver = get_solver(cfg)
              if restore:
                  solver.restore(
                      load_best=load_best,
                      ignore_state_keys=ignore_state_keys,
                  )
          return solver
      finally:
          hydra.core.global_hydra.GlobalHydra.instance().clear()
  
file_path: audiocraft/audiocraft/train.py
imports: import logging
  import multiprocessing
  import os
  from pathlib import Path
  import sys
  import typing
  from dora import git_save, hydra_main, XP
  import flashy
  import hydra
  import omegaconf
  from .environment import AudioCraftEnvironment
  from .utils.cluster import get_slurm_parameters
label_desc: Use image node_id 3 for calling a global function with example usage: get_solver_from_xp(xp, override_cfg, restore, load_best, ignore_state_keys, disable_fsdp) and returns: solver