code: def get_compression_model(
      cfg: omegaconf.DictConfig,
  ) -> CompressionModel:
      """Instantiate a compression model."""
      if cfg.compression_model == "encodec":
          kwargs = dict_from_config(getattr(cfg, "encodec"))
          encoder_name = kwargs.pop("autoencoder")
          quantizer_name = kwargs.pop("quantizer")
          encoder, decoder = get_encodec_autoencoder(encoder_name, cfg)
          quantizer = get_quantizer(
              quantizer_name, cfg, encoder.dimension
          )
          frame_rate = kwargs["sample_rate"] // encoder.hop_length
          renormalize = kwargs.pop("renormalize", False)
          # deprecated params
          kwargs.pop("renorm", None)
          return EncodecModel(
              encoder,
              decoder,
              quantizer,
              frame_rate=frame_rate,
              renormalize=renormalize,
              **kwargs,
          ).to(cfg.device)
      else:
          raise KeyError(
              f"Unexpected compression model {cfg.compression_model}"
          )
  
imports: import typing
  import audiocraft
  import omegaconf
  import torch
  from .encodec import CompressionModel, EncodecModel, InterleaveStereoCompressionModel
  from .lm import LMModel
  from .lm_magnet import MagnetLMModel
  from ..modules.codebooks_patterns import CodebooksPatternProvider, DelayedPatternProvider, MusicLMPattern, ParallelPatternProvider, UnrolledPatternProvider, CoarseFirstPattern
  from ..modules.conditioners import BaseConditioner, ChromaStemConditioner, CLAPEmbeddingConditioner, ConditionFuser, ConditioningProvider, LUTConditioner, T5Conditioner
  from .unet import DiffusionUnet
  from ..None import quantization
  from ..utils.utils import dict_from_config
  from ..modules.diffusion_schedule import MultiBandProcessor, SampleProcessor
label_desc: Use image node_id 3 for calling a global function with example usage: get_compression_model(cfg) and returns: EncodecModel