code: def _clean_lm_cfg(cfg: DictConfig):
      OmegaConf.set_struct(cfg, False)
      # This used to be set automatically in the LM solver, need a more robust solution
      # for the future.
      cfg["transformer_lm"]["card"] = 2048
      n_q = 4
      stereo_cfg = getattr(cfg, "interleave_stereo_codebooks", None)
      if stereo_cfg is not None and stereo_cfg.use:
          if "downsample" in stereo_cfg:
              del stereo_cfg["downsample"]
          n_q = 8
      cfg["transformer_lm"]["n_q"] = n_q
      # Experimental params no longer supported.
      bad_params = [
          "spectral_norm_attn_iters",
          "spectral_norm_ff_iters",
          "residual_balancer_attn",
          "residual_balancer_ff",
          "layer_drop",
      ]
      for name in bad_params:
          del cfg["transformer_lm"][name]
      OmegaConf.set_struct(cfg, True)
      return cfg
  
file_path: audiocraft/audiocraft/utils/export_legacy.py
imports: from pathlib import Path
  import typing
  from omegaconf import OmegaConf, DictConfig
  import torch
  from audiocraft import __version__
label_desc: Use image node_id 1 for calling a global function with example usage: _clean_lm_cfg(cfg) and returns: cfg