class_docstr: Base generative model with convenient generation API.
  
  Args:
      name (str): name of the model.
      compression_model (CompressionModel): Compression model
          used to map audio to invertible discrete representations.
      lm (LMModel): Language model over discrete representations.
      max_duration (float, optional): maximum duration the model can produce,
          otherwise, inferred from the training params.
code: def __init__(
      self,
      name: str,
      compression_model: CompressionModel,
      lm: LMModel,
      max_duration: tp.Optional[float] = None,
  ):
      self.name = name
      self.compression_model = compression_model
      self.lm = lm
      self.cfg: tp.Optional[omegaconf.DictConfig] = None
      # Just to be safe, let's put everything in eval mode.
      self.compression_model.eval()
      self.lm.eval()
  
      if hasattr(lm, "cfg"):
          cfg = lm.cfg
          assert isinstance(cfg, omegaconf.DictConfig)
          self.cfg = cfg
  
      if self.cfg is not None:
          self.compression_model = get_wrapped_compression_model(
              self.compression_model, self.cfg
          )
  
      if max_duration is None:
          if self.cfg is not None:
              max_duration = lm.cfg.dataset.segment_duration  # type: ignore
          else:
              raise ValueError(
                  "You must provide max_duration when building directly your GenModel"
              )
      assert max_duration is not None
  
      self.max_duration: float = max_duration
      self.duration = self.max_duration
  
      # self.extend_stride is the length of audio extension when generating samples longer
      # than self.max_duration. NOTE: the derived class must set self.extend_stride to a
      # positive float value when generating with self.duration > self.max_duration.
      self.extend_stride: tp.Optional[float] = None
      self.device = next(iter(lm.parameters())).device
      self.generation_params: dict = {}
      self._progress_callback: tp.Optional[
          tp.Callable[[int, int], None]
      ] = None
      if self.device.type == "cpu":
          self.autocast = TorchAutocast(enabled=False)
      else:
          self.autocast = TorchAutocast(
              enabled=True,
              device_type=self.device.type,
              dtype=torch.float16,
          )
  
imports: from abc import ABC, abstractmethod
  import typing
  import omegaconf
  import torch
  from .encodec import CompressionModel
  from .lm import LMModel
  from .builders import get_wrapped_compression_model
  from ..data.audio_utils import convert_audio
  from ..modules.conditioners import ConditioningAttributes
  from ..utils.autocast import TorchAutocast
label_desc: Use image node_id 1 to create a new BaseGenModel object from inherited base classes: ABC with example: obj = BaseGenModel(name, compression_model, lm, max_duration)