class_docstr: MusicGen main 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.
class_docstr_tok: ["MusicGen","main","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","."]
docstr: Generate samples conditioned on text and melody.
  
  Args:
      descriptions (list of str): A list of strings used as text conditioning.
      melody_wavs: (torch.Tensor or list of Tensor): A batch of waveforms used as
          melody conditioning. Should have shape [B, C, T] with B matching the description length,
          C=1 or 2. It can be [C, T] if there is a single description. It can also be
          a list of [C, T] tensors.
      melody_sample_rate: (int): Sample rate of the melody waveforms.
      progress (bool, optional): Flag to display progress of the generation process. Defaults to False.
docstr_tok: ["Generate","samples","conditioned","on","text","and","melody",".","Args",":","descriptions","(","list","of","str",")",":","A","list","of","strings","used","as","text","conditioning",".","melody_wavs",":","(","torch.Tensor","or","list","of","Tensor",")",":","A","batch","of","waveforms","used","as","melody","conditioning",".","Should","have","shape","[","B",",","C",",","T","]","with","B","matching","the","description","length",",","C=1","or","2",".","It","can","be","[","C",",","T","]","if","there","is","a","single","description",".","It","can","also","be","a","list","of","[","C",",","T","]","tensors",".","melody_sample_rate",":","(","int",")",":","Sample","rate","of","the","melody","waveforms",".","progress","(","bool",",","optional",")",":","Flag","to","display","progress","of","the","generation","process",".","Defaults","to","False","."]
code: def generate_with_chroma(
      self,
      descriptions: tp.List[str],
      melody_wavs: MelodyType,
      melody_sample_rate: int,
      progress: bool = False,
      return_tokens: bool = False,
  ) -> tp.Union[torch.Tensor, tp.Tuple[torch.Tensor, torch.Tensor]]:
      """Generate samples conditioned on text and melody.
  
      Args:
          descriptions (list of str): A list of strings used as text conditioning.
          melody_wavs: (torch.Tensor or list of Tensor): A batch of waveforms used as
              melody conditioning. Should have shape [B, C, T] with B matching the description length,
              C=1 or 2. It can be [C, T] if there is a single description. It can also be
              a list of [C, T] tensors.
          melody_sample_rate: (int): Sample rate of the melody waveforms.
          progress (bool, optional): Flag to display progress of the generation process. Defaults to False.
      """
      if isinstance(melody_wavs, torch.Tensor):
          if melody_wavs.dim() == 2:
              melody_wavs = melody_wavs[None]
          if melody_wavs.dim() != 3:
              raise ValueError(
                  "Melody wavs should have a shape [B, C, T]."
              )
          melody_wavs = list(melody_wavs)
      else:
          for melody in melody_wavs:
              if melody is not None:
                  assert (
                      melody.dim() == 2
                  ), "One melody in the list has the wrong number of dims."
  
      melody_wavs = [
          convert_audio(
              wav,
              melody_sample_rate,
              self.sample_rate,
              self.audio_channels,
          )
          if wav is not None
          else None
          for wav in melody_wavs
      ]
      attributes, prompt_tokens = self._prepare_tokens_and_attributes(
          descriptions=descriptions,
          prompt=None,
          melody_wavs=melody_wavs,
      )
      assert prompt_tokens is None
      tokens = self._generate_tokens(
          attributes, prompt_tokens, progress
      )
      if return_tokens:
          return self.generate_audio(tokens), tokens
      return self.generate_audio(tokens)
  
file_path: audiocraft/audiocraft/models/musicgen.py
imports: import typing
  import warnings
  import torch
  from .encodec import CompressionModel
  from .genmodel import BaseGenModel
  from .lm import LMModel
  from .builders import get_debug_compression_model, get_debug_lm_model
  from .loaders import load_compression_model, load_lm_model
  from ..data.audio_utils import convert_audio
  from ..modules.conditioners import ConditioningAttributes, WavCondition
label_desc: Use image node_id 4 for calling the MusicGen obj's underlying member method code with example usage: obj.generate_with_chroma(descriptions, melody_wavs, melody_sample_rate, progress, return_tokens) and returns: self, self,  tokens