code: def export_encodec(
      checkpoint_path: tp.Union[Path, str],
      out_file: tp.Union[Path, str],
  ):
      """Export only the best state from the given EnCodec checkpoint. This
      should be used if you trained your own EnCodec model.
      """
      pkg = torch.load(checkpoint_path, "cpu")
      new_pkg = {
          "best_state": pkg["best_state"]["model"],
          "xp.cfg": OmegaConf.to_yaml(pkg["xp.cfg"]),
          "version": __version__,
          "exported": True,
      }
      Path(out_file).parent.mkdir(exist_ok=True, parents=True)
      torch.save(new_pkg, out_file)
      return out_file
  
file_path: audiocraft/audiocraft/utils/export.py
imports: from pathlib import Path
  import typing
  from omegaconf import OmegaConf
  import torch
  from audiocraft import __version__
label_desc: Use image node_id 1 for calling a global function with example usage: export_encodec(checkpoint_path, out_file) and returns: out_file