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: Set the generation parameters for MusicGen.
  
  Args:
      use_sampling (bool, optional): Use sampling if True, else do argmax decoding. Defaults to True.
      top_k (int, optional): top_k used for sampling. Defaults to 250.
      top_p (float, optional): top_p used for sampling, when set to 0 top_k is used. Defaults to 0.0.
      temperature (float, optional): Softmax temperature parameter. Defaults to 1.0.
      duration (float, optional): Duration of the generated waveform. Defaults to 30.0.
      cfg_coef (float, optional): Coefficient used for classifier free guidance. Defaults to 3.0.
      two_step_cfg (bool, optional): If True, performs 2 forward for Classifier Free Guidance,
          instead of batching together the two. This has some impact on how things
          are padded but seems to have little impact in practice.
      extend_stride: when doing extended generation (i.e. more than 30 seconds), by how much
          should we extend the audio each time. Larger values will mean less context is
          preserved, and shorter value will require extra computations.
docstr_tok: ["Set","the","generation","parameters","for","MusicGen",".","Args",":","use_sampling","(","bool",",","optional",")",":","Use","sampling","if","True",",","else","do","argmax","decoding",".","Defaults","to","True",".","top_k","(","int",",","optional",")",":","top_k","used","for","sampling",".","Defaults","to","250.","top_p","(","float",",","optional",")",":","top_p","used","for","sampling",",","when","set","to","0","top_k","is","used",".","Defaults","to","0.0.","temperature","(","float",",","optional",")",":","Softmax","temperature","parameter",".","Defaults","to","1.0.","duration","(","float",",","optional",")",":","Duration","of","the","generated","waveform",".","Defaults","to","30.0.","cfg_coef","(","float",",","optional",")",":","Coefficient","used","for","classifier","free","guidance",".","Defaults","to","3.0.","two_step_cfg","(","bool",",","optional",")",":","If","True",",","performs","2","forward","for","Classifier","Free","Guidance",",","instead","of","batching","together","the","two",".","This","has","some","impact","on","how","things","are","padded","but","seems","to","have","little","impact","in","practice",".","extend_stride",":","when","doing","extended","generation","(","i.e",".","more","than","30","seconds",")",",","by","how","much","should","we","extend","the","audio","each","time",".","Larger","values","will","mean","less","context","is","preserved",",","and","shorter","value","will","require","extra","computations","."]
code: def set_generation_params(
      self,
      use_sampling: bool = True,
      top_k: int = 250,
      top_p: float = 0.0,
      temperature: float = 1.0,
      duration: float = 30.0,
      cfg_coef: float = 3.0,
      two_step_cfg: bool = False,
      extend_stride: float = 18,
  ):
      """Set the generation parameters for MusicGen.
  
      Args:
          use_sampling (bool, optional): Use sampling if True, else do argmax decoding. Defaults to True.
          top_k (int, optional): top_k used for sampling. Defaults to 250.
          top_p (float, optional): top_p used for sampling, when set to 0 top_k is used. Defaults to 0.0.
          temperature (float, optional): Softmax temperature parameter. Defaults to 1.0.
          duration (float, optional): Duration of the generated waveform. Defaults to 30.0.
          cfg_coef (float, optional): Coefficient used for classifier free guidance. Defaults to 3.0.
          two_step_cfg (bool, optional): If True, performs 2 forward for Classifier Free Guidance,
              instead of batching together the two. This has some impact on how things
              are padded but seems to have little impact in practice.
          extend_stride: when doing extended generation (i.e. more than 30 seconds), by how much
              should we extend the audio each time. Larger values will mean less context is
              preserved, and shorter value will require extra computations.
      """
      assert (
          extend_stride < self.max_duration
      ), "Cannot stride by more than max generation duration."
      self.extend_stride = extend_stride
      self.duration = duration
      self.generation_params = {
          "use_sampling": use_sampling,
          "temp": temperature,
          "top_k": top_k,
          "top_p": top_p,
          "cfg_coef": cfg_coef,
          "two_step_cfg": two_step_cfg,
      }
  
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 3 for calling the MusicGen obj's underlying member method code with example usage: obj.set_generation_params(use_sampling, top_k, top_p, temperature, duration, cfg_coef, two_step_cfg, extend_stride) without return types