import{S as Uh,i as Eh,s as $h,e as a,k as c,w as f,t as n,M as Fh,c as r,d as t,m as p,a as i,x as g,h as s,b as d,G as o,g as h,y as _,q as b,o as M,B as y,v as Wh,L as Zh}from"../../chunks/vendor-hf-doc-builder.js";import{T as vc}from"../../chunks/Tip-hf-doc-builder.js";import{D as W}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Y}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as F}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Gh}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Nh(N){let m,j,w,T,k;return T=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBNdXNpY2dlbkNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyME11c2ljZ2VuRGVjb2RlckNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFQ1Q29uZmlnJTJDJTBBJTIwJTIwJTIwJTIwRW5jb2RlY0NvbmZpZyUyQyUwQSUyMCUyMCUyMCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTJDJTBBKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMHRleHQlMjBlbmNvZGVyJTJDJTIwYXVkaW8lMjBlbmNvZGVyJTJDJTIwYW5kJTIwZGVjb2RlciUyMG1vZGVsJTIwY29uZmlndXJhdGlvbnMlMEF0ZXh0X2VuY29kZXJfY29uZmlnJTIwJTNEJTIwVDVDb25maWcoKSUwQWF1ZGlvX2VuY29kZXJfY29uZmlnJTIwJTNEJTIwRW5jb2RlY0NvbmZpZygpJTBBZGVjb2Rlcl9jb25maWclMjAlM0QlMjBNdXNpY2dlbkRlY29kZXJDb25maWcoKSUwQSUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBNdXNpY2dlbkNvbmZpZy5mcm9tX3N1Yl9tb2RlbHNfY29uZmlnKCUwQSUyMCUyMCUyMCUyMHRleHRfZW5jb2Rlcl9jb25maWclMkMlMjBhdWRpb19lbmNvZGVyX2NvbmZpZyUyQyUyMGRlY29kZXJfY29uZmlnJTBBKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwTXVzaWNnZW5Gb3JDb25kaXRpb25hbEdlbmVyYXRpb24oY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmlnJTBBY29uZmlnX3RleHRfZW5jb2RlciUyMCUzRCUyMG1vZGVsLmNvbmZpZy50ZXh0X2VuY29kZXIlMEFjb25maWdfYXVkaW9fZW5jb2RlciUyMCUzRCUyMG1vZGVsLmNvbmZpZy5hdWRpb19lbmNvZGVyJTBBY29uZmlnX2RlY29kZXIlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2RlciUwQSUwQSUyMyUyMFNhdmluZyUyMHRoZSUyMG1vZGVsJTJDJTIwaW5jbHVkaW5nJTIwaXRzJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJtdXNpY2dlbi1tb2RlbCUyMiklMEElMEElMjMlMjBsb2FkaW5nJTIwbW9kZWwlMjBhbmQlMjBjb25maWclMjBmcm9tJTIwcHJldHJhaW5lZCUyMGZvbGRlciUwQW11c2ljZ2VuX2NvbmZpZyUyMCUzRCUyME11c2ljZ2VuQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJtdXNpY2dlbi1tb2RlbCUyMiklMEFtb2RlbCUyMCUzRCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtdXNpY2dlbi1tb2RlbCUyMiUyQyUyMGNvbmZpZyUzRG11c2ljZ2VuX2NvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    MusicgenConfig,
<span class="hljs-meta">... </span>    MusicgenDecoderConfig,
<span class="hljs-meta">... </span>    T5Config,
<span class="hljs-meta">... </span>    EncodecConfig,
<span class="hljs-meta">... </span>    MusicgenForConditionalGeneration,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing text encoder, audio encoder, and decoder model configurations</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>text_encoder_config = T5Config()
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_encoder_config = EncodecConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_config = MusicgenDecoderConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = MusicgenConfig.from_sub_models_config(
<span class="hljs-meta">... </span>    text_encoder_config, audio_encoder_config, decoder_config
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a MusicgenForConditionalGeneration (with random weights) from the facebook/musicgen-small style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config
<span class="hljs-meta">&gt;&gt;&gt; </span>config_text_encoder = model.config.text_encoder
<span class="hljs-meta">&gt;&gt;&gt; </span>config_audio_encoder = model.config.audio_encoder
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = model.config.decoder

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Saving the model, including its configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;musicgen-model&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># loading model and config from pretrained folder</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>musicgen_config = MusicgenConfig.from_pretrained(<span class="hljs-string">&quot;musicgen-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;musicgen-model&quot;</span>, config=musicgen_config)`}}),{c(){m=a("p"),j=n("Example:"),w=c(),f(T.$$.fragment)},l(u){m=r(u,"P",{});var v=i(m);j=s(v,"Example:"),v.forEach(t),w=p(u),g(T.$$.fragment,u)},m(u,v){h(u,m,v),o(m,j),h(u,w,v),_(T,u,v),k=!0},p:Zh,i(u){k||(b(T.$$.fragment,u),k=!0)},o(u){M(T.$$.fragment,u),k=!1},d(u){u&&t(m),u&&t(w),y(T,u)}}}function xh(N){let m,j,w,T,k;return{c(){m=a("p"),j=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=a("code"),T=n("Module"),k=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){m=r(u,"P",{});var v=i(m);j=s(v,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r(v,"CODE",{});var E=i(w);T=s(E,"Module"),E.forEach(t),k=s(v,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),v.forEach(t)},m(u,v){h(u,m,v),o(m,j),o(m,w),o(w,T),o(m,k)},d(u){u&&t(m)}}}function zh(N){let m,j,w,T,k;return{c(){m=a("p"),j=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=a("code"),T=n("Module"),k=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){m=r(u,"P",{});var v=i(m);j=s(v,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r(v,"CODE",{});var E=i(w);T=s(E,"Module"),E.forEach(t),k=s(v,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),v.forEach(t)},m(u,v){h(u,m,v),o(m,j),o(m,w),o(w,T),o(m,k)},d(u){u&&t(m)}}}function Ih(N){let m,j,w,T,k;return{c(){m=a("p"),j=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),w=a("code"),T=n("Module"),k=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(u){m=r(u,"P",{});var v=i(m);j=s(v,"Although the recipe for forward pass needs to be defined within this function, one should call the "),w=r(v,"CODE",{});var E=i(w);T=s(E,"Module"),E.forEach(t),k=s(v,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),v.forEach(t)},m(u,v){h(u,m,v),o(m,j),o(m,w),o(w,T),o(m,k)},d(u){u&&t(m)}}}function Rh(N){let m,j,w,T,k;return T=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiklMEFtb2RlbCUyMCUzRCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm11c2ljZ2VuLXNtYWxsJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvciglMEElMjAlMjAlMjAlMjB0ZXh0JTNEJTVCJTIyODBzJTIwcG9wJTIwdHJhY2slMjB3aXRoJTIwYmFzc3klMjBkcnVtcyUyMGFuZCUyMHN5bnRoJTIyJTJDJTIwJTIyOTBzJTIwcm9jayUyMHNvbmclMjB3aXRoJTIwbG91ZCUyMGd1aXRhcnMlMjBhbmQlMjBoZWF2eSUyMGRydW1zJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcGFkZGluZyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKSUwQSUwQXBhZF90b2tlbl9pZCUyMCUzRCUyMG1vZGVsLmdlbmVyYXRpb25fY29uZmlnLnBhZF90b2tlbl9pZCUwQWRlY29kZXJfaW5wdXRfaWRzJTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMHRvcmNoLm9uZXMoKGlucHV0cy5pbnB1dF9pZHMuc2hhcGUlNUIwJTVEJTIwKiUyMG1vZGVsLmRlY29kZXIubnVtX2NvZGVib29rcyUyQyUyMDEpJTJDJTIwZHR5cGUlM0R0b3JjaC5sb25nKSUwQSUyMCUyMCUyMCUyMColMjBwYWRfdG9rZW5faWQlMEEpJTBBJTBBbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBkZWNvZGVyX2lucHV0X2lkcyUzRGRlY29kZXJfaW5wdXRfaWRzKS5sb2dpdHMlMEFsb2dpdHMuc2hhcGUlMjAlMjAlMjMlMjAoYnN6JTIwKiUyMG51bV9jb2RlYm9va3MlMkMlMjB0Z3RfbGVuJTJDJTIwdm9jYWJfc2l6ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, MusicgenForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(
<span class="hljs-meta">... </span>    text=[<span class="hljs-string">&quot;80s pop track with bassy drums and synth&quot;</span>, <span class="hljs-string">&quot;90s rock song with loud guitars and heavy drums&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>pad_token_id = model.generation_config.pad_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = (
<span class="hljs-meta">... </span>    torch.ones((inputs.input_ids.shape[<span class="hljs-number">0</span>] * model.decoder.num_codebooks, <span class="hljs-number">1</span>), dtype=torch.long)
<span class="hljs-meta">... </span>    * pad_token_id
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs, decoder_input_ids=decoder_input_ids).logits
<span class="hljs-meta">&gt;&gt;&gt; </span>logits.shape  <span class="hljs-comment"># (bsz * num_codebooks, tgt_len, vocab_size)</span>
torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2048</span>])`}}),{c(){m=a("p"),j=n("Examples:"),w=c(),f(T.$$.fragment)},l(u){m=r(u,"P",{});var v=i(m);j=s(v,"Examples:"),v.forEach(t),w=p(u),g(T.$$.fragment,u)},m(u,v){h(u,m,v),o(m,j),h(u,w,v),_(T,u,v),k=!0},p:Zh,i(u){k||(b(T.$$.fragment,u),k=!0)},o(u){M(T.$$.fragment,u),k=!1},d(u){u&&t(m),u&&t(w),y(T,u)}}}function Xh(N){let m,j,w,T,k,u,v,E,er,fs,te,ve,rn,no,or,ln,tr,gs,we,nr,so,sr,ar,_s,Te,rr,dn,ir,lr,bs,ut,dr,Ms,mt,cr,ys,ft,cn,pr,vs,x,hr,ao,ur,mr,ro,fr,gr,io,_r,br,ws,ne,ke,pn,lo,Mr,hn,yr,Ts,S,vr,un,wr,Tr,mn,kr,jr,ks,se,je,fn,co,Jr,gn,Cr,js,Je,Gr,_n,Zr,Ur,Js,po,Cs,Ce,Er,bn,$r,Fr,Gs,ho,Zs,D,Wr,Mn,Nr,xr,yn,zr,Ir,Us,uo,Es,ae,Ge,vn,mo,Rr,wn,Xr,$s,Ze,Br,gt,qr,Vr,Fs,fo,Ws,z,Yr,Tn,Ar,Pr,kn,Sr,Dr,jn,Qr,Hr,Ns,re,Ue,Jn,go,Lr,Cn,Or,xs,Ee,Kr,_t,ei,oi,zs,_o,Is,bo,Rs,Q,ti,Gn,ni,si,bt,ai,ri,Xs,Mo,Bs,ie,$e,Zn,yo,ii,Un,li,qs,Mt,di,Vs,vo,Ys,I,ci,En,pi,hi,$n,ui,mi,Fn,fi,gi,As,le,Fe,Wn,wo,_i,Nn,bi,Ps,yt,Mi,Ss,H,xn,yi,vi,zn,wi,Ti,In,ki,Ds,L,ji,vt,Ji,Ci,wt,Gi,Zi,Qs,O,Ui,Tt,Ei,$i,kt,Fi,Wi,Hs,We,Ni,jt,xi,zi,Ls,To,Os,Ne,Ii,Rn,Ri,Xi,Ks,ko,ea,Jt,Bi,oa,xe,Xn,qi,Vi,ze,Yi,Bn,Ai,Pi,qn,Si,ta,de,Ie,Vn,jo,Di,Yn,Qi,na,A,Jo,Hi,ce,Li,An,Oi,Ki,Co,el,ol,tl,pe,nl,Ct,sl,al,Gt,rl,il,sa,he,Re,Pn,Go,ll,Sn,dl,aa,J,Zo,cl,Uo,pl,Zt,hl,ul,ml,ue,fl,Ut,gl,_l,Et,bl,Ml,yl,Xe,vl,Be,Eo,wl,$o,Tl,$t,kl,jl,Jl,qe,Fo,Cl,Wo,Gl,Ft,Zl,Ul,ra,me,Ve,Dn,No,El,Qn,$l,ia,U,xo,Fl,Hn,Wl,Nl,$,Wt,xl,zl,Nt,Il,Rl,Ln,Xl,Bl,On,ql,Vl,xt,Yl,Al,Pl,Ye,zo,Sl,Io,Dl,zt,Ql,Hl,Ll,Ae,Ro,Ol,Xo,Kl,It,ed,od,la,fe,Pe,Kn,Bo,td,es,nd,da,C,qo,sd,os,ad,rd,Vo,id,Yo,ld,dd,cd,Ao,pd,Rt,hd,ud,md,Po,fd,So,gd,_d,bd,K,Do,Md,ge,yd,Xt,vd,wd,ts,Td,kd,jd,Se,ca,_e,De,ns,Qo,Jd,ss,Cd,pa,G,Ho,Gd,as,Zd,Ud,Lo,Ed,Oo,$d,Fd,Wd,Ko,Nd,Bt,xd,zd,Id,et,Rd,ot,Xd,Bd,qd,ee,tt,Vd,be,Yd,qt,Ad,Pd,rs,Sd,Dd,Qd,Qe,ha,Me,He,is,nt,Hd,ls,Ld,ua,Z,st,Od,ds,Kd,ec,at,oc,rt,tc,nc,sc,it,ac,Vt,rc,ic,lc,lt,dc,dt,cc,pc,hc,R,ct,uc,ye,mc,Yt,fc,gc,cs,_c,bc,Mc,Le,yc,Oe,ma;return u=new F({}),no=new F({}),lo=new F({}),co=new F({}),po=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiklMEF1bmNvbmRpdGlvbmFsX2lucHV0cyUyMCUzRCUyMG1vZGVsLmdldF91bmNvbmRpdGlvbmFsX2lucHV0cyhudW1fc2FtcGxlcyUzRDEpJTBBJTBBYXVkaW9fdmFsdWVzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKip1bmNvbmRpdGlvbmFsX2lucHV0cyUyQyUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDI1Nik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MusicgenForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>unconditional_inputs = model.get_unconditional_inputs(num_samples=<span class="hljs-number">1</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>audio_values = model.generate(**unconditional_inputs, do_sample=<span class="hljs-literal">True</span>, max_new_tokens=<span class="hljs-number">256</span>)`}}),ho=new Y({props:{code:"ZnJvbSUyMElQeXRob24uZGlzcGxheSUyMGltcG9ydCUyMEF1ZGlvJTBBJTBBc2FtcGxpbmdfcmF0ZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5hdWRpb19lbmNvZGVyLnNhbXBsaW5nX3JhdGUlMEFBdWRpbyhhdWRpb192YWx1ZXMlNUIwJTVELm51bXB5KCklMkMlMjByYXRlJTNEc2FtcGxpbmdfcmF0ZSk=",highlighted:`<span class="hljs-keyword">from</span> IPython.display <span class="hljs-keyword">import</span> Audio

sampling_rate = model.config.audio_encoder.sampling_rate
Audio(audio_values[<span class="hljs-number">0</span>].numpy(), rate=sampling_rate)`}}),uo=new Y({props:{code:"aW1wb3J0JTIwc2NpcHklMEElMEFzYW1wbGluZ19yYXRlJTIwJTNEJTIwbW9kZWwuY29uZmlnLmF1ZGlvX2VuY29kZXIuc2FtcGxpbmdfcmF0ZSUwQXNjaXB5LmlvLndhdmZpbGUud3JpdGUoJTIybXVzaWNnZW5fb3V0LndhdiUyMiUyQyUyMHJhdGUlM0RzYW1wbGluZ19yYXRlJTJDJTIwZGF0YSUzRGF1ZGlvX3ZhbHVlcyU1QjAlMkMlMjAwJTVELm51bXB5KCkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> scipy

<span class="hljs-meta">&gt;&gt;&gt; </span>sampling_rate = model.config.audio_encoder.sampling_rate
<span class="hljs-meta">&gt;&gt;&gt; </span>scipy.io.wavfile.write(<span class="hljs-string">&quot;musicgen_out.wav&quot;</span>, rate=sampling_rate, data=audio_values[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>].numpy())`}}),mo=new F({}),fo=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGbXVzaWNnZW4tc21hbGwlMjIpJTBBbW9kZWwlMjAlM0QlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoJTBBJTIwJTIwJTIwJTIwdGV4dCUzRCU1QiUyMjgwcyUyMHBvcCUyMHRyYWNrJTIwd2l0aCUyMGJhc3N5JTIwZHJ1bXMlMjBhbmQlMjBzeW50aCUyMiUyQyUyMCUyMjkwcyUyMHJvY2slMjBzb25nJTIwd2l0aCUyMGxvdWQlMjBndWl0YXJzJTIwYW5kJTIwaGVhdnklMjBkcnVtcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSklMEFhdWRpb192YWx1ZXMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDI1Nik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, MusicgenForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(
<span class="hljs-meta">... </span>    text=[<span class="hljs-string">&quot;80s pop track with bassy drums and synth&quot;</span>, <span class="hljs-string">&quot;90s rock song with loud guitars and heavy drums&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_values = model.generate(**inputs, do_sample=<span class="hljs-literal">True</span>, guidance_scale=<span class="hljs-number">3</span>, max_new_tokens=<span class="hljs-number">256</span>)`}}),go=new F({}),_o=new Y({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHBpcCUwQXBpcCUyMGluc3RhbGwlMjBkYXRhc2V0cyU1QmF1ZGlvJTVE",highlighted:`pip <span class="hljs-keyword">install</span> --upgrade pip
pip <span class="hljs-keyword">install</span> datasets[audio]`}}),bo=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGbXVzaWNnZW4tc21hbGwlMjIpJTBBbW9kZWwlMjAlM0QlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiklMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMnNhbmNoaXQtZ2FuZGhpJTJGZ3R6YW4lMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyJTJDJTIwc3RyZWFtaW5nJTNEVHJ1ZSklMEFzYW1wbGUlMjAlM0QlMjBuZXh0KGl0ZXIoZGF0YXNldCkpJTVCJTIyYXVkaW8lMjIlNUQlMEElMEElMjMlMjB0YWtlJTIwdGhlJTIwZmlyc3QlMjBoYWxmJTIwb2YlMjB0aGUlMjBhdWRpbyUyMHNhbXBsZSUwQXNhbXBsZSU1QiUyMmFycmF5JTIyJTVEJTIwJTNEJTIwc2FtcGxlJTVCJTIyYXJyYXklMjIlNUQlNUIlM0ElMjBsZW4oc2FtcGxlJTVCJTIyYXJyYXklMjIlNUQpJTIwJTJGJTJGJTIwMiU1RCUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvciglMEElMjAlMjAlMjAlMjBhdWRpbyUzRHNhbXBsZSU1QiUyMmFycmF5JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2FtcGxpbmdfcmF0ZSUzRHNhbXBsZSU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB0ZXh0JTNEJTVCJTIyODBzJTIwYmx1ZXMlMjB0cmFjayUyMHdpdGglMjBncm9vdnklMjBzYXhvcGhvbmUlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMEEpJTBBYXVkaW9fdmFsdWVzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBkb19zYW1wbGUlM0RUcnVlJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0QzJTJDJTIwbWF4X25ld190b2tlbnMlM0QyNTYp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, MusicgenForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;sanchit-gandhi/gtzan&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset))[<span class="hljs-string">&quot;audio&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># take the first half of the audio sample</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>sample[<span class="hljs-string">&quot;array&quot;</span>] = sample[<span class="hljs-string">&quot;array&quot;</span>][: <span class="hljs-built_in">len</span>(sample[<span class="hljs-string">&quot;array&quot;</span>]) // <span class="hljs-number">2</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(
<span class="hljs-meta">... </span>    audio=sample[<span class="hljs-string">&quot;array&quot;</span>],
<span class="hljs-meta">... </span>    sampling_rate=sample[<span class="hljs-string">&quot;sampling_rate&quot;</span>],
<span class="hljs-meta">... </span>    text=[<span class="hljs-string">&quot;80s blues track with groovy saxophone&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_values = model.generate(**inputs, do_sample=<span class="hljs-literal">True</span>, guidance_scale=<span class="hljs-number">3</span>, max_new_tokens=<span class="hljs-number">256</span>)`}}),Mo=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGbXVzaWNnZW4tc21hbGwlMjIpJTBBbW9kZWwlMjAlM0QlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiklMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMnNhbmNoaXQtZ2FuZGhpJTJGZ3R6YW4lMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyJTJDJTIwc3RyZWFtaW5nJTNEVHJ1ZSklMEFzYW1wbGUlMjAlM0QlMjBuZXh0KGl0ZXIoZGF0YXNldCkpJTVCJTIyYXVkaW8lMjIlNUQlMEElMEElMjMlMjB0YWtlJTIwdGhlJTIwZmlyc3QlMjBxdWFydGVyJTIwb2YlMjB0aGUlMjBhdWRpbyUyMHNhbXBsZSUwQXNhbXBsZV8xJTIwJTNEJTIwc2FtcGxlJTVCJTIyYXJyYXklMjIlNUQlNUIlM0ElMjBsZW4oc2FtcGxlJTVCJTIyYXJyYXklMjIlNUQpJTIwJTJGJTJGJTIwNCU1RCUwQSUwQSUyMyUyMHRha2UlMjB0aGUlMjBmaXJzdCUyMGhhbGYlMjBvZiUyMHRoZSUyMGF1ZGlvJTIwc2FtcGxlJTBBc2FtcGxlXzIlMjAlM0QlMjBzYW1wbGUlNUIlMjJhcnJheSUyMiU1RCU1QiUzQSUyMGxlbihzYW1wbGUlNUIlMjJhcnJheSUyMiU1RCklMjAlMkYlMkYlMjAyJTVEJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKCUwQSUyMCUyMCUyMCUyMGF1ZGlvJTNEJTVCc2FtcGxlXzElMkMlMjBzYW1wbGVfMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNhbXBsaW5nX3JhdGUlM0RzYW1wbGUlNUIlMjJzYW1wbGluZ19yYXRlJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdGV4dCUzRCU1QiUyMjgwcyUyMGJsdWVzJTIwdHJhY2slMjB3aXRoJTIwZ3Jvb3Z5JTIwc2F4b3Bob25lJTIyJTJDJTIwJTIyOTBzJTIwcm9jayUyMHNvbmclMjB3aXRoJTIwbG91ZCUyMGd1aXRhcnMlMjBhbmQlMjBoZWF2eSUyMGRydW1zJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcGFkZGluZyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKSUwQWF1ZGlvX3ZhbHVlcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEMyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMjU2KSUwQSUwQSUyMyUyMHBvc3QtcHJvY2VzcyUyMHRvJTIwcmVtb3ZlJTIwcGFkZGluZyUyMGZyb20lMjB0aGUlMjBiYXRjaGVkJTIwYXVkaW8lMEFhdWRpb192YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGF1ZGlvX3ZhbHVlcyUyQyUyMHBhZGRpbmdfbWFzayUzRGlucHV0cy5wYWRkaW5nX21hc2sp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, MusicgenForConditionalGeneration
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;sanchit-gandhi/gtzan&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset))[<span class="hljs-string">&quot;audio&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># take the first quarter of the audio sample</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>sample_1 = sample[<span class="hljs-string">&quot;array&quot;</span>][: <span class="hljs-built_in">len</span>(sample[<span class="hljs-string">&quot;array&quot;</span>]) // <span class="hljs-number">4</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># take the first half of the audio sample</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>sample_2 = sample[<span class="hljs-string">&quot;array&quot;</span>][: <span class="hljs-built_in">len</span>(sample[<span class="hljs-string">&quot;array&quot;</span>]) // <span class="hljs-number">2</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(
<span class="hljs-meta">... </span>    audio=[sample_1, sample_2],
<span class="hljs-meta">... </span>    sampling_rate=sample[<span class="hljs-string">&quot;sampling_rate&quot;</span>],
<span class="hljs-meta">... </span>    text=[<span class="hljs-string">&quot;80s blues track with groovy saxophone&quot;</span>, <span class="hljs-string">&quot;90s rock song with loud guitars and heavy drums&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_values = model.generate(**inputs, do_sample=<span class="hljs-literal">True</span>, guidance_scale=<span class="hljs-number">3</span>, max_new_tokens=<span class="hljs-number">256</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># post-process to remove padding from the batched audio</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_values = processor.batch_decode(audio_values, padding_mask=inputs.padding_mask)`}}),yo=new F({}),vo=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBNdXNpY2dlbkZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiklMEElMEElMjMlMjBpbnNwZWN0JTIwdGhlJTIwZGVmYXVsdCUyMGdlbmVyYXRpb24lMjBjb25maWclMEFtb2RlbC5nZW5lcmF0aW9uX2NvbmZpZyUwQSUwQSUyMyUyMGluY3JlYXNlJTIwdGhlJTIwZ3VpZGFuY2UlMjBzY2FsZSUyMHRvJTIwNC4wJTBBbW9kZWwuZ2VuZXJhdGlvbl9jb25maWcuZ3VpZGFuY2Vfc2NhbGUlMjAlM0QlMjA0LjAlMEElMEElMjMlMjBkZWNyZWFzZSUyMHRoZSUyMG1heCUyMGxlbmd0aCUyMHRvJTIwMjU2JTIwdG9rZW5zJTBBbW9kZWwuZ2VuZXJhdGlvbl9jb25maWcubWF4X2xlbmd0aCUyMCUzRCUyMDI1Ng==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MusicgenForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># inspect the default generation config</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># increase the guidance scale to 4.0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config.guidance_scale = <span class="hljs-number">4.0</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># decrease the max length to 256 tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config.max_length = <span class="hljs-number">256</span>`}}),wo=new F({}),To=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMkMlMjBBdXRvTW9kZWxGb3JUZXh0RW5jb2RpbmclMkMlMjBBdXRvTW9kZWwlMkMlMjBNdXNpY2dlbkZvckNhdXNhbExNJTJDJTIwTXVzaWNnZW5Gb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEF0ZXh0X2VuY29kZXIlMjAlM0QlMjBBdXRvTW9kZWxGb3JUZXh0RW5jb2RpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMnQ1LWJhc2UlMjIpJTBBYXVkaW9fZW5jb2RlciUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZlbmNvZGVjXzMya2h6JTIyKSUwQWRlY29kZXJfY29uZmlnJTIwJTNEJTIwQXV0b0NvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMikuZGVjb2RlciUwQWRlY29kZXIlMjAlM0QlMjBNdXNpY2dlbkZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm11c2ljZ2VuLXNtYWxsJTIyJTJDJTIwKipkZWNvZGVyX2NvbmZpZyklMEElMEFtb2RlbCUyMCUzRCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fc3ViX21vZGVsc19wcmV0cmFpbmVkKHRleHRfZW5jb2RlciUyQyUyMGF1ZGlvX2VuY29kZXIlMkMlMjBkZWNvZGVyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig, AutoModelForTextEncoding, AutoModel, MusicgenForCausalLM, MusicgenForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>text_encoder = AutoModelForTextEncoding.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_encoder = AutoModel.from_pretrained(<span class="hljs-string">&quot;facebook/encodec_32khz&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>).decoder
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder = MusicgenForCausalLM.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>, **decoder_config)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = MusicgenForConditionalGeneration.from_sub_models_pretrained(text_encoder, audio_encoder, decoder)`}}),ko=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMkMlMjBNdXNpY2dlbkZvckNhdXNhbExNJTJDJTIwTXVzaWNnZW5Gb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEElMjMlMjBPcHRpb24lMjAxJTNBJTIwZ2V0JTIwZGVjb2RlciUyMGNvbmZpZyUyMGFuZCUyMHBhc3MlMjB0byUyMCU2MC5mcm9tX3ByZXRyYWluZWQlNjAlMEFkZWNvZGVyX2NvbmZpZyUyMCUzRCUyMEF1dG9Db25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGbXVzaWNnZW4tc21hbGwlMjIpLmRlY29kZXIlMEFkZWNvZGVyJTIwJTNEJTIwTXVzaWNnZW5Gb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtdXNpY2dlbi1zbWFsbCUyMiUyQyUyMCoqZGVjb2Rlcl9jb25maWcpJTBBJTBBJTIzJTIwT3B0aW9uJTIwMiUzQSUyMGxvYWQlMjB0aGUlMjBlbnRpcmUlMjBjb21wb3NpdGUlMjBtb2RlbCUyQyUyMGJ1dCUyMG9ubHklMjByZXR1cm4lMjB0aGUlMjBkZWNvZGVyJTBBZGVjb2RlciUyMCUzRCUyME11c2ljZ2VuRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm11c2ljZ2VuLXNtYWxsJTIyKS5kZWNvZGVy",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig, MusicgenForCausalLM, MusicgenForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Option 1: get decoder config and pass to \`.from_pretrained\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>).decoder
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder = MusicgenForCausalLM.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>, **decoder_config)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Option 2: load the entire composite model, but only return the decoder</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder = MusicgenForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;facebook/musicgen-small&quot;</span>).decoder`}}),jo=new F({}),Jo=new W({props:{name:"class transformers.MusicgenDecoderConfig",anchor:"transformers.MusicgenDecoderConfig",parameters:[{name:"vocab_size",val:" = 2048"},{name:"max_position_embeddings",val:" = 2048"},{name:"num_hidden_layers",val:" = 24"},{name:"ffn_dim",val:" = 4096"},{name:"num_attention_heads",val:" = 16"},{name:"layerdrop",val:" = 0.0"},{name:"use_cache",val:" = True"},{name:"activation_function",val:" = 'gelu'"},{name:"hidden_size",val:" = 1024"},{name:"dropout",val:" = 0.1"},{name:"attention_dropout",val:" = 0.0"},{name:"activation_dropout",val:" = 0.0"},{name:"initializer_factor",val:" = 0.02"},{name:"scale_embedding",val:" = False"},{name:"num_codebooks",val:" = 4"},{name:"pad_token_id",val:" = 2048"},{name:"bos_token_id",val:" = 2048"},{name:"eos_token_id",val:" = None"},{name:"tie_word_embeddings",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MusicgenDecoderConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Vocabulary size of the MusicgenDecoder model. Defines the number of different tokens that can be
represented by the <code>inputs_ids</code> passed when calling <code>MusicgenDecoder</code>.`,name:"vocab_size"},{anchor:"transformers.MusicgenDecoderConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimensionality of the layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.MusicgenDecoderConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 24) &#x2014;
Number of decoder layers.`,name:"num_hidden_layers"},{anchor:"transformers.MusicgenDecoderConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer block.`,name:"num_attention_heads"},{anchor:"transformers.MusicgenDecoderConfig.ffn_dim",description:`<strong>ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in the Transformer block.`,name:"ffn_dim"},{anchor:"transformers.MusicgenDecoderConfig.activation_function",description:`<strong>activation_function</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the decoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"activation_function"},{anchor:"transformers.MusicgenDecoderConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, text_encoder, and pooler.`,name:"dropout"},{anchor:"transformers.MusicgenDecoderConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.MusicgenDecoderConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for activations inside the fully connected layer.`,name:"activation_dropout"},{anchor:"transformers.MusicgenDecoderConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
The maximum sequence length that this model might ever be used with. Typically, set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.MusicgenDecoderConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_factor"},{anchor:"transformers.MusicgenDecoderConfig.layerdrop",description:`<strong>layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The LayerDrop probability for the decoder. See the [LayerDrop paper](see <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a>)
for more details.`,name:"layerdrop"},{anchor:"transformers.MusicgenDecoderConfig.scale_embedding",description:`<strong>scale_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Scale embeddings by diving by sqrt(hidden_size).`,name:"scale_embedding"},{anchor:"transformers.MusicgenDecoderConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the model should return the last key/values attentions (not used by all models)`,name:"use_cache"},{anchor:"transformers.MusicgenDecoderConfig.num_codebooks",description:`<strong>num_codebooks</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The number of parallel codebooks forwarded to the model.`,name:"num_codebooks"},{anchor:"transformers.MusicgenDecoderConfig.tie_word_embeddings(bool,",description:`<strong>tie_word_embeddings(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether input and output word embeddings should be tied.`,name:"tie_word_embeddings(bool,"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/configuration_musicgen.py#L31"}}),Go=new F({}),Zo=new W({props:{name:"class transformers.MusicgenConfig",anchor:"transformers.MusicgenConfig",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MusicgenConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments. Notably:</p>
<ul>
<li><strong>text_encoder</strong> (<a href="/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that
defines the text encoder config.</li>
<li><strong>audio_encoder</strong> (<a href="/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that
defines the audio encoder config.</li>
<li><strong>decoder</strong> (<a href="/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that defines
the decoder config.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/configuration_musicgen.py#L130"}}),Xe=new Gh({props:{anchor:"transformers.MusicgenConfig.example",$$slots:{default:[Nh]},$$scope:{ctx:N}}}),Eo=new W({props:{name:"from_sub_models_config",anchor:"transformers.MusicgenConfig.from_sub_models_config",parameters:[{name:"text_encoder_config",val:": PretrainedConfig"},{name:"audio_encoder_config",val:": PretrainedConfig"},{name:"decoder_config",val:": MusicgenDecoderConfig"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/configuration_musicgen.py#L208",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig"
>MusicgenConfig</a></p>
`}}),Fo=new W({props:{name:"to_dict",anchor:"transformers.MusicgenConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/configuration_musicgen.py#L231",returnDescription:`
<p>Dictionary of all the attributes that make up this configuration instance,</p>
`,returnType:`
<p><code>Dict[str, any]</code></p>
`}}),No=new F({}),xo=new W({props:{name:"class transformers.MusicgenProcessor",anchor:"transformers.MusicgenProcessor",parameters:[{name:"feature_extractor",val:""},{name:"tokenizer",val:""}],parametersDescription:[{anchor:"transformers.MusicgenProcessor.feature_extractor",description:`<strong>feature_extractor</strong> (<code>EncodecFeatureExtractor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecFeatureExtractor">EncodecFeatureExtractor</a>. The feature extractor is a required input.`,name:"feature_extractor"},{anchor:"transformers.MusicgenProcessor.tokenizer",description:`<strong>tokenizer</strong> (<code>T5Tokenizer</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.31.0/en/model_doc/t5#transformers.T5Tokenizer">T5Tokenizer</a>. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/processing_musicgen.py#L26"}}),zo=new W({props:{name:"batch_decode",anchor:"transformers.MusicgenProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/processing_musicgen.py#L89"}}),Ro=new W({props:{name:"decode",anchor:"transformers.MusicgenProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/processing_musicgen.py#L107"}}),Bo=new F({}),qo=new W({props:{name:"class transformers.MusicgenModel",anchor:"transformers.MusicgenModel",parameters:[{name:"config",val:": MusicgenDecoderConfig"}],parametersDescription:[{anchor:"transformers.MusicgenModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig">MusicgenConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/modeling_musicgen.py#L898"}}),Do=new W({props:{name:"forward",anchor:"transformers.MusicgenModel.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MusicgenModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * num_codebooks, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary, corresponding to the sequence of audio codes.</p>
<p>Indices can be obtained by encoding an audio prompt with an audio encoder model to predict audio codes,
such as with the <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel.encode">EncodecModel.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>The <code>input_ids</code> will automatically be converted from shape <code>(batch_size * num_codebooks, target_sequence_length)</code> to <code>(batch_size, num_codebooks, target_sequence_length)</code> in the forward pass. If
you obtain audio codes from an audio encoding model, such as <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>, ensure that the number of
frames is equal to 1, and that you reshape the audio codes from <code>(frames, batch_size, num_codebooks, target_sequence_length)</code> to <code>(batch_size * num_codebooks, target_sequence_length)</code> prior to passing them as
<code>input_ids</code>.</p>

					</div>`,name:"input_ids"},{anchor:"transformers.MusicgenModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.MusicgenModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, encoder_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention of
the decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.MusicgenModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, encoder_sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing cross-attention on padding tokens indices of encoder input_ids. Mask values
selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"encoder_attention_mask"},{anchor:"transformers.MusicgenModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MusicgenModel.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules in the decoder to avoid performing
cross-attention on hidden heads. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"cross_attn_head_mask"},{anchor:"transformers.MusicgenModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>. inputs_embeds (<code>torch.FloatTensor</code> of shape
<code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>): Optionally, instead of passing <code>input_ids</code> you
can choose to directly pass an embedded representation. This is useful if you want more control over how to
convert <code>input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"past_key_values"},{anchor:"transformers.MusicgenModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.MusicgenModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.MusicgenModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/modeling_musicgen.py#L914"}}),Se=new vc({props:{$$slots:{default:[xh]},$$scope:{ctx:N}}}),Qo=new F({}),Ho=new W({props:{name:"class transformers.MusicgenForCausalLM",anchor:"transformers.MusicgenForCausalLM",parameters:[{name:"config",val:": MusicgenDecoderConfig"}],parametersDescription:[{anchor:"transformers.MusicgenForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig">MusicgenConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/modeling_musicgen.py#L969"}}),tt=new W({props:{name:"forward",anchor:"transformers.MusicgenForCausalLM.forward",parameters:[{name:"input_ids",val:": LongTensor = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MusicgenForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * num_codebooks, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary, corresponding to the sequence of audio codes.</p>
<p>Indices can be obtained by encoding an audio prompt with an audio encoder model to predict audio codes,
such as with the <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel.encode">EncodecModel.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>The <code>input_ids</code> will automatically be converted from shape <code>(batch_size * num_codebooks, target_sequence_length)</code> to <code>(batch_size, num_codebooks, target_sequence_length)</code> in the forward pass. If
you obtain audio codes from an audio encoding model, such as <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>, ensure that the number of
frames is equal to 1, and that you reshape the audio codes from <code>(frames, batch_size, num_codebooks, target_sequence_length)</code> to <code>(batch_size * num_codebooks, target_sequence_length)</code> prior to passing them as
<code>input_ids</code>.</p>

					</div>`,name:"input_ids"},{anchor:"transformers.MusicgenForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.MusicgenForCausalLM.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, encoder_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention of
the decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.MusicgenForCausalLM.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, encoder_sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing cross-attention on padding tokens indices of encoder input_ids. Mask values
selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"encoder_attention_mask"},{anchor:"transformers.MusicgenForCausalLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MusicgenForCausalLM.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules in the decoder to avoid performing
cross-attention on hidden heads. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"cross_attn_head_mask"},{anchor:"transformers.MusicgenForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>. inputs_embeds (<code>torch.FloatTensor</code> of shape
<code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>): Optionally, instead of passing <code>input_ids</code> you
can choose to directly pass an embedded representation. This is useful if you want more control over how to
convert <code>input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"past_key_values"},{anchor:"transformers.MusicgenForCausalLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.MusicgenForCausalLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.MusicgenForCausalLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MusicgenForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code> Indices are selected in <code>[-100, 0, ..., config.vocab_size]</code> All labels set to <code>-100</code>
are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size]</code></p>
<p>Returns:
<a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput">transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code>: A <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput">transformers.modeling_outputs.Seq2SeqLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a href="/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig">MusicgenConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) &#x2014; Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) &#x2014; Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014; Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) &#x2014; Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) &#x2014; Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) &#x2014; Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder&#x2019;s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014; Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) &#x2014; Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) &#x2014; Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/modeling_musicgen.py#L1001"}}),Qe=new vc({props:{$$slots:{default:[zh]},$$scope:{ctx:N}}}),nt=new F({}),st=new W({props:{name:"class transformers.MusicgenForConditionalGeneration",anchor:"transformers.MusicgenForConditionalGeneration",parameters:[{name:"config",val:": typing.Optional[transformers.models.musicgen.configuration_musicgen.MusicgenConfig] = None"},{name:"text_encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"audio_encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"decoder",val:": typing.Optional[transformers.models.musicgen.modeling_musicgen.MusicgenForCausalLM] = None"}],parametersDescription:[{anchor:"transformers.MusicgenForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig">MusicgenConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/modeling_musicgen.py#L1448"}}),ct=new W({props:{name:"forward",anchor:"transformers.MusicgenForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"input_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"padding_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"past_key_values",val:": typing.Tuple[typing.Tuple[torch.FloatTensor]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MusicgenForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size * num_codebooks, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary, corresponding to the sequence of audio codes.</p>
<p>Indices can be obtained by encoding an audio prompt with an audio encoder model to predict audio codes,
such as with the <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel.encode">EncodecModel.encode()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>The <code>decoder_input_ids</code> will automatically be converted from shape <code>(batch_size * num_codebooks, target_sequence_length)</code> to <code>(batch_size, num_codebooks, target_sequence_length)</code> in the forward pass. If
you obtain audio codes from an audio encoding model, such as <a href="/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>, ensure that the number of
frames is equal to 1, and that you reshape the audio codes from <code>(frames, batch_size, num_codebooks, target_sequence_length)</code> to <code>(batch_size * num_codebooks, target_sequence_length)</code> prior to passing them as
<code>decoder_input_ids</code>.</p>

					</div>`,name:"decoder_input_ids"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(encoder_layers, encoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the encoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"decoder_head_mask"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"cross_attn_head_mask"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) is a sequence of
hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>. inputs_embeds (<code>torch.FloatTensor</code> of shape
<code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>): Optionally, instead of passing <code>input_ids</code> you
can choose to directly pass an embedded representation. This is useful if you want more control over how to
convert <code>input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"past_key_values"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.</p>
<p>If <code>decoder_input_ids</code> and <code>decoder_inputs_embeds</code> are both unset, <code>decoder_inputs_embeds</code> takes the value
of <code>inputs_embeds</code>.`,name:"decoder_inputs_embeds"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.MusicgenForConditionalGeneration.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/musicgen/modeling_musicgen.py#L1804",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig"
>MusicgenConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Le=new vc({props:{$$slots:{default:[Ih]},$$scope:{ctx:N}}}),Oe=new Gh({props:{anchor:"transformers.MusicgenForConditionalGeneration.forward.example",$$slots:{default:[Rh]},$$scope:{ctx:N}}}),{c(){m=a("meta"),j=c(),w=a("h1"),T=a("a"),k=a("span"),f(u.$$.fragment),v=c(),E=a("span"),er=n("MusicGen"),fs=c(),te=a("h2"),ve=a("a"),rn=a("span"),f(no.$$.fragment),or=c(),ln=a("span"),tr=n("Overview"),gs=c(),we=a("p"),nr=n("The MusicGen model was proposed in the paper "),so=a("a"),sr=n("Simple and Controllable Music Generation"),ar=n(`
by Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi and Alexandre D\xE9fossez.`),_s=c(),Te=a("p"),rr=n(`MusicGen is a single stage auto-regressive Transformer model capable of generating high-quality music samples conditioned
on text descriptions or audio prompts. The text descriptions are passed through a frozen text encoder model to obtain a
sequence of hidden-state representations. MusicGen is then trained to predict discrete audio tokens, or `),dn=a("em"),ir=n("audio codes"),lr=n(`,
conditioned on these hidden-states. These audio tokens are then decoded using an audio compression model, such as EnCodec,
to recover the audio waveform.`),bs=c(),ut=a("p"),dr=n(`Through an efficient token interleaving pattern, MusicGen does not require a self-supervised semantic representation of
the text/audio prompts, thus eliminating the need to cascade multiple models to predict a set of codebooks (e.g.
hierarchically or upsampling). Instead, it is able to generate all the codebooks in a single forward pass.`),Ms=c(),mt=a("p"),cr=n("The abstract from the paper is the following:"),ys=c(),ft=a("p"),cn=a("em"),pr=n(`We tackle the task of conditional music generation. We introduce MusicGen, a single Language Model (LM) that operates
over several streams of compressed discrete music representation, i.e., tokens. Unlike prior work, MusicGen is comprised
of a single-stage transformer LM together with efficient token interleaving patterns, which eliminates the need for
cascading several models, e.g., hierarchically or upsampling. Following this approach, we demonstrate how MusicGen
can generate high-quality samples, while being conditioned on textual description or melodic features, allowing better
controls over the generated output. We conduct extensive empirical evaluation, considering both automatic and human
studies, showing the proposed approach is superior to the evaluated baselines on a standard text-to-music benchmark.
Through ablation studies, we shed light over the importance of each of the components comprising MusicGen.`),vs=c(),x=a("p"),hr=n("This model was contributed by "),ao=a("a"),ur=n("sanchit-gandhi"),mr=n(`. The original code can be found
`),ro=a("a"),fr=n("here"),gr=n(`. The pre-trained checkpoints can be found on the
`),io=a("a"),_r=n("Hugging Face Hub"),br=n("."),ws=c(),ne=a("h2"),ke=a("a"),pn=a("span"),f(lo.$$.fragment),Mr=c(),hn=a("span"),yr=n("Generation"),Ts=c(),S=a("p"),vr=n(`MusicGen is compatible with two generation modes: greedy and sampling. In practice, sampling leads to significantly
better results than greedy, thus we encourage sampling mode to be used where possible. Sampling is enabled by default,
and can be explicitly specified by setting `),un=a("code"),wr=n("do_sample=True"),Tr=n(" in the call to "),mn=a("code"),kr=n("MusicgenForConditionalGeneration.generate()"),jr=n(`,
or by overriding the model\u2019s generation config (see below).`),ks=c(),se=a("h3"),je=a("a"),fn=a("span"),f(co.$$.fragment),Jr=c(),gn=a("span"),Cr=n("Unconditional Generation"),js=c(),Je=a("p"),Gr=n(`The inputs for unconditional (or \u2018null\u2019) generation can be obtained through the method
`),_n=a("code"),Zr=n("MusicgenForConditionalGeneration.get_unconditional_inputs()"),Ur=n(":"),Js=c(),f(po.$$.fragment),Cs=c(),Ce=a("p"),Er=n("The audio outputs are a three-dimensional Torch tensor of shape "),bn=a("code"),$r=n("(batch_size, num_channels, sequence_length)"),Fr=n(`. To listen
to the generated audio samples, you can either play them in an ipynb notebook:`),Gs=c(),f(ho.$$.fragment),Zs=c(),D=a("p"),Wr=n("Or save them as a "),Mn=a("code"),Nr=n(".wav"),xr=n(" file using a third-party library, e.g. "),yn=a("code"),zr=n("scipy"),Ir=n(":"),Us=c(),f(uo.$$.fragment),Es=c(),ae=a("h3"),Ge=a("a"),vn=a("span"),f(mo.$$.fragment),Rr=c(),wn=a("span"),Xr=n("Text-Conditional Generation"),$s=c(),Ze=a("p"),Br=n("The model can generate an audio sample conditioned on a text prompt through use of the "),gt=a("a"),qr=n("MusicgenProcessor"),Vr=n(` to pre-process
the inputs:`),Fs=c(),f(fo.$$.fragment),Ws=c(),z=a("p"),Yr=n("The "),Tn=a("code"),Ar=n("guidance_scale"),Pr=n(` is used in classifier free guidance (CFG), setting the weighting between the conditional logits
(which are predicted from the text prompts) and the unconditional logits (which are predicted from an unconditional or
\u2018null\u2019 prompt). Higher guidance scale encourages the model to generate samples that are more closely linked to the input
prompt, usually at the expense of poorer audio quality. CFG is enabled by setting `),kn=a("code"),Sr=n("guidance_scale > 1"),Dr=n(`. For best results,
use `),jn=a("code"),Qr=n("guidance_scale=3"),Hr=n(" (default)."),Ns=c(),re=a("h3"),Ue=a("a"),Jn=a("span"),f(go.$$.fragment),Lr=c(),Cn=a("span"),Or=n("Audio-Prompted Generation"),xs=c(),Ee=a("p"),Kr=n("The same "),_t=a("a"),ei=n("MusicgenProcessor"),oi=n(` can be used to pre-process an audio prompt that is used for audio continuation. In the
following example, we load an audio file using the \u{1F917} Datasets library, which can be pip installed through the command
below:`),zs=c(),f(_o.$$.fragment),Is=c(),f(bo.$$.fragment),Rs=c(),Q=a("p"),ti=n("For batched audio-prompted generation, the generated "),Gn=a("code"),ni=n("audio_values"),si=n(` can be post-processed to remove padding by using the
`),bt=a("a"),ai=n("MusicgenProcessor"),ri=n(" class:"),Xs=c(),f(Mo.$$.fragment),Bs=c(),ie=a("h3"),$e=a("a"),Zn=a("span"),f(yo.$$.fragment),ii=c(),Un=a("span"),li=n("Generation Configuration"),qs=c(),Mt=a("p"),di=n(`The default parameters that control the generation process, such as sampling, guidance scale and number of generated
tokens, can be found in the model\u2019s generation config, and updated as desired:`),Vs=c(),f(vo.$$.fragment),Ys=c(),I=a("p"),ci=n("Note that any arguments passed to the generate method will "),En=a("strong"),pi=n("supersede"),hi=n(` those in the generation config, so setting
`),$n=a("code"),ui=n("do_sample=False"),mi=n(" in the call to generate will supersede the setting of "),Fn=a("code"),fi=n("model.generation_config.do_sample"),gi=n(` in the
generation config.`),As=c(),le=a("h2"),Fe=a("a"),Wn=a("span"),f(wo.$$.fragment),_i=c(),Nn=a("span"),bi=n("Model Structure"),Ps=c(),yt=a("p"),Mi=n("The MusicGen model can be de-composed into three distinct stages:"),Ss=c(),H=a("ol"),xn=a("li"),yi=n("Text encoder: maps the text inputs to a sequence of hidden-state representations. The pre-trained MusicGen models use a frozen text encoder from either T5 or Flan-T5"),vi=c(),zn=a("li"),wi=n("MusicGen decoder: a language model (LM) that auto-regressively generates audio tokens (or codes) conditional on the encoder hidden-state representations"),Ti=c(),In=a("li"),ki=n("Audio encoder/decoder: used to encode an audio prompt to use as prompt tokens, and recover the audio waveform from the audio tokens predicted by the decoder"),Ds=c(),L=a("p"),ji=n("Thus, the MusicGen model can either be used as a standalone decoder model, corresponding to the class "),vt=a("a"),Ji=n("MusicgenForCausalLM"),Ci=n(`,
or as a composite model that includes the text encoder and audio encoder/decoder, corresponding to the class
`),wt=a("a"),Gi=n("MusicgenForConditionalGeneration"),Zi=n("."),Qs=c(),O=a("p"),Ui=n("Since the text encoder and audio encoder/decoder models are frozen during training, the MusicGen decoder "),Tt=a("a"),Ei=n("MusicgenForCausalLM"),$i=n(`
can be trained standalone on a dataset of encoder hidden-states and audio codes. For inference, the trained decoder can
be combined with the frozen text encoder and audio encoder/decoders to recover the composite `),kt=a("a"),Fi=n("MusicgenForConditionalGeneration"),Wi=n(`
model.`),Hs=c(),We=a("p"),Ni=n("Below, we demonstrate how to construct the composite "),jt=a("a"),xi=n("MusicgenForConditionalGeneration"),zi=n(` model from its three constituent
parts, as would typically be done following training of the MusicGen decoder LM:`),Ls=c(),f(To.$$.fragment),Os=c(),Ne=a("p"),Ii=n(`If only the decoder needs to be loaded from the pre-trained checkpoint for the composite model, it can be loaded by first
specifying the correct config, or be accessed through the `),Rn=a("code"),Ri=n(".decoder"),Xi=n(" attribute of the composite model:"),Ks=c(),f(ko.$$.fragment),ea=c(),Jt=a("p"),Bi=n("Tips:"),oa=c(),xe=a("ul"),Xn=a("li"),qi=n("MusicGen is trained on the 32kHz checkpoint of Encodec. You should ensure you use a compatible version of the Encodec model."),Vi=c(),ze=a("li"),Yi=n("Sampling mode tends to deliver better results than greedy - you can toggle sampling with the variable "),Bn=a("code"),Ai=n("do_sample"),Pi=n(" in the call to "),qn=a("code"),Si=n("MusicgenForConditionalGeneration.generate()"),ta=c(),de=a("h2"),Ie=a("a"),Vn=a("span"),f(jo.$$.fragment),Di=c(),Yn=a("span"),Qi=n("MusicgenDecoderConfig"),na=c(),A=a("div"),f(Jo.$$.fragment),Hi=c(),ce=a("p"),Li=n("This is the configuration class to store the configuration of an "),An=a("code"),Oi=n("MusicgenDecoder"),Ki=n(`. It is used to instantiate a
MusicGen decoder according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the MusicGen
`),Co=a("a"),el=n("facebook/musicgen-small"),ol=n(" architecture."),tl=c(),pe=a("p"),nl=n("Configuration objects inherit from "),Ct=a("a"),sl=n("PretrainedConfig"),al=n(` and can be used to control the model outputs. Read the
documentation from `),Gt=a("a"),rl=n("PretrainedConfig"),il=n(" for more information."),sa=c(),he=a("h2"),Re=a("a"),Pn=a("span"),f(Go.$$.fragment),ll=c(),Sn=a("span"),dl=n("MusicgenConfig"),aa=c(),J=a("div"),f(Zo.$$.fragment),cl=c(),Uo=a("p"),pl=n("This is the configuration class to store the configuration of a "),Zt=a("a"),hl=n("MusicgenModel"),ul=n(`. It is used to instantiate a
MusicGen model according to the specified arguments, defining the text encoder, audio encoder and MusicGen decoder
configs.`),ml=c(),ue=a("p"),fl=n("Configuration objects inherit from "),Ut=a("a"),gl=n("PretrainedConfig"),_l=n(` and can be used to control the model outputs. Read the
documentation from `),Et=a("a"),bl=n("PretrainedConfig"),Ml=n(" for more information."),yl=c(),f(Xe.$$.fragment),vl=c(),Be=a("div"),f(Eo.$$.fragment),wl=c(),$o=a("p"),Tl=n("Instantiate a "),$t=a("a"),kl=n("MusicgenConfig"),jl=n(` (or a derived class) from text encoder, audio encoder and decoder
configurations.`),Jl=c(),qe=a("div"),f(Fo.$$.fragment),Cl=c(),Wo=a("p"),Gl=n("Serializes this instance to a Python dictionary. Override the default "),Ft=a("a"),Zl=n("to_dict()"),Ul=n("."),ra=c(),me=a("h2"),Ve=a("a"),Dn=a("span"),f(No.$$.fragment),El=c(),Qn=a("span"),$l=n("MusicgenProcessor"),ia=c(),U=a("div"),f(xo.$$.fragment),Fl=c(),Hn=a("p"),Wl=n(`Constructs a MusicGen processor which wraps an EnCodec feature extractor and a T5 tokenizer into a single processor
class.`),Nl=c(),$=a("p"),Wt=a("a"),xl=n("MusicgenProcessor"),zl=n(" offers all the functionalities of "),Nt=a("a"),Il=n("EncodecFeatureExtractor"),Rl=n(" and "),Ln=a("code"),Xl=n("TTokenizer"),Bl=n(`. See
`),On=a("code"),ql=n("__call__()"),Vl=n(" and "),xt=a("a"),Yl=n("decode()"),Al=n(" for more information."),Pl=c(),Ye=a("div"),f(zo.$$.fragment),Sl=c(),Io=a("p"),Dl=n(`This method is used to decode either batches of audio outputs from the MusicGen model, or batches of token ids
from the tokenizer. In the case of decoding token ids, this method forwards all its arguments to T5Tokenizer\u2019s
`),zt=a("a"),Ql=n("batch_decode()"),Hl=n(". Please refer to the docstring of this method for more information."),Ll=c(),Ae=a("div"),f(Ro.$$.fragment),Ol=c(),Xo=a("p"),Kl=n("This method forwards all its arguments to T5Tokenizer\u2019s "),It=a("a"),ed=n("decode()"),od=n(`. Please refer to the
docstring of this method for more information.`),la=c(),fe=a("h2"),Pe=a("a"),Kn=a("span"),f(Bo.$$.fragment),td=c(),es=a("span"),nd=n("MusicgenModel"),da=c(),C=a("div"),f(qo.$$.fragment),sd=c(),os=a("p"),ad=n("The bare Musicgen decoder model outputting raw hidden-states without any specific head on top."),rd=c(),Vo=a("p"),id=n("The Musicgen model was proposed in "),Yo=a("a"),ld=n("Simple and Controllable Music Generation"),dd=n(` by
Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre D\xE9fossez. It is an
encoder decoder transformer trained on the task of conditional music generation`),cd=c(),Ao=a("p"),pd=n("This model inherits from "),Rt=a("a"),hd=n("PreTrainedModel"),ud=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),md=c(),Po=a("p"),fd=n("This model is also a PyTorch "),So=a("a"),gd=n("torch.nn.Module"),_d=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),bd=c(),K=a("div"),f(Do.$$.fragment),Md=c(),ge=a("p"),yd=n("The "),Xt=a("a"),vd=n("MusicgenModel"),wd=n(" forward method, overrides the "),ts=a("code"),Td=n("__call__"),kd=n(" special method."),jd=c(),f(Se.$$.fragment),ca=c(),_e=a("h2"),De=a("a"),ns=a("span"),f(Qo.$$.fragment),Jd=c(),ss=a("span"),Cd=n("MusicgenForCausalLM"),pa=c(),G=a("div"),f(Ho.$$.fragment),Gd=c(),as=a("p"),Zd=n("The MusicGen decoder model with a language modelling head on top."),Ud=c(),Lo=a("p"),Ed=n("The Musicgen model was proposed in "),Oo=a("a"),$d=n("Simple and Controllable Music Generation"),Fd=n(` by
Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre D\xE9fossez. It is an
encoder decoder transformer trained on the task of conditional music generation`),Wd=c(),Ko=a("p"),Nd=n("This model inherits from "),Bt=a("a"),xd=n("PreTrainedModel"),zd=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Id=c(),et=a("p"),Rd=n("This model is also a PyTorch "),ot=a("a"),Xd=n("torch.nn.Module"),Bd=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),qd=c(),ee=a("div"),f(tt.$$.fragment),Vd=c(),be=a("p"),Yd=n("The "),qt=a("a"),Ad=n("MusicgenForCausalLM"),Pd=n(" forward method, overrides the "),rs=a("code"),Sd=n("__call__"),Dd=n(" special method."),Qd=c(),f(Qe.$$.fragment),ha=c(),Me=a("h2"),He=a("a"),is=a("span"),f(nt.$$.fragment),Hd=c(),ls=a("span"),Ld=n("MusicgenForConditionalGeneration"),ua=c(),Z=a("div"),f(st.$$.fragment),Od=c(),ds=a("p"),Kd=n("The composite MusicGen model with a text encoder, audio encoder and Musicgen decoder,for music generation tasks with one or both of text and audio prompts."),ec=c(),at=a("p"),oc=n("The Musicgen model was proposed in "),rt=a("a"),tc=n("Simple and Controllable Music Generation"),nc=n(` by
Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre D\xE9fossez. It is an
encoder decoder transformer trained on the task of conditional music generation`),sc=c(),it=a("p"),ac=n("This model inherits from "),Vt=a("a"),rc=n("PreTrainedModel"),ic=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),lc=c(),lt=a("p"),dc=n("This model is also a PyTorch "),dt=a("a"),cc=n("torch.nn.Module"),pc=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),hc=c(),R=a("div"),f(ct.$$.fragment),uc=c(),ye=a("p"),mc=n("The "),Yt=a("a"),fc=n("MusicgenForConditionalGeneration"),gc=n(" forward method, overrides the "),cs=a("code"),_c=n("__call__"),bc=n(" special method."),Mc=c(),f(Le.$$.fragment),yc=c(),f(Oe.$$.fragment),this.h()},l(e){const l=Fh('[data-svelte="svelte-1phssyn"]',document.head);m=r(l,"META",{name:!0,content:!0}),l.forEach(t),j=p(e),w=r(e,"H1",{class:!0});var pt=i(w);T=r(pt,"A",{id:!0,class:!0,href:!0});var ps=i(T);k=r(ps,"SPAN",{});var hs=i(k);g(u.$$.fragment,hs),hs.forEach(t),ps.forEach(t),v=p(pt),E=r(pt,"SPAN",{});var us=i(E);er=s(us,"MusicGen"),us.forEach(t),pt.forEach(t),fs=p(e),te=r(e,"H2",{class:!0});var ht=i(te);ve=r(ht,"A",{id:!0,class:!0,href:!0});var wc=i(ve);rn=r(wc,"SPAN",{});var Tc=i(rn);g(no.$$.fragment,Tc),Tc.forEach(t),wc.forEach(t),or=p(ht),ln=r(ht,"SPAN",{});var kc=i(ln);tr=s(kc,"Overview"),kc.forEach(t),ht.forEach(t),gs=p(e),we=r(e,"P",{});var fa=i(we);nr=s(fa,"The MusicGen model was proposed in the paper "),so=r(fa,"A",{href:!0,rel:!0});var jc=i(so);sr=s(jc,"Simple and Controllable Music Generation"),jc.forEach(t),ar=s(fa,`
by Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi and Alexandre D\xE9fossez.`),fa.forEach(t),_s=p(e),Te=r(e,"P",{});var ga=i(Te);rr=s(ga,`MusicGen is a single stage auto-regressive Transformer model capable of generating high-quality music samples conditioned
on text descriptions or audio prompts. The text descriptions are passed through a frozen text encoder model to obtain a
sequence of hidden-state representations. MusicGen is then trained to predict discrete audio tokens, or `),dn=r(ga,"EM",{});var Jc=i(dn);ir=s(Jc,"audio codes"),Jc.forEach(t),lr=s(ga,`,
conditioned on these hidden-states. These audio tokens are then decoded using an audio compression model, such as EnCodec,
to recover the audio waveform.`),ga.forEach(t),bs=p(e),ut=r(e,"P",{});var Cc=i(ut);dr=s(Cc,`Through an efficient token interleaving pattern, MusicGen does not require a self-supervised semantic representation of
the text/audio prompts, thus eliminating the need to cascade multiple models to predict a set of codebooks (e.g.
hierarchically or upsampling). Instead, it is able to generate all the codebooks in a single forward pass.`),Cc.forEach(t),Ms=p(e),mt=r(e,"P",{});var Gc=i(mt);cr=s(Gc,"The abstract from the paper is the following:"),Gc.forEach(t),ys=p(e),ft=r(e,"P",{});var Zc=i(ft);cn=r(Zc,"EM",{});var Uc=i(cn);pr=s(Uc,`We tackle the task of conditional music generation. We introduce MusicGen, a single Language Model (LM) that operates
over several streams of compressed discrete music representation, i.e., tokens. Unlike prior work, MusicGen is comprised
of a single-stage transformer LM together with efficient token interleaving patterns, which eliminates the need for
cascading several models, e.g., hierarchically or upsampling. Following this approach, we demonstrate how MusicGen
can generate high-quality samples, while being conditioned on textual description or melodic features, allowing better
controls over the generated output. We conduct extensive empirical evaluation, considering both automatic and human
studies, showing the proposed approach is superior to the evaluated baselines on a standard text-to-music benchmark.
Through ablation studies, we shed light over the importance of each of the components comprising MusicGen.`),Uc.forEach(t),Zc.forEach(t),vs=p(e),x=r(e,"P",{});var Ke=i(x);hr=s(Ke,"This model was contributed by "),ao=r(Ke,"A",{href:!0,rel:!0});var Ec=i(ao);ur=s(Ec,"sanchit-gandhi"),Ec.forEach(t),mr=s(Ke,`. The original code can be found
`),ro=r(Ke,"A",{href:!0,rel:!0});var $c=i(ro);fr=s($c,"here"),$c.forEach(t),gr=s(Ke,`. The pre-trained checkpoints can be found on the
`),io=r(Ke,"A",{href:!0,rel:!0});var Fc=i(io);_r=s(Fc,"Hugging Face Hub"),Fc.forEach(t),br=s(Ke,"."),Ke.forEach(t),ws=p(e),ne=r(e,"H2",{class:!0});var _a=i(ne);ke=r(_a,"A",{id:!0,class:!0,href:!0});var Wc=i(ke);pn=r(Wc,"SPAN",{});var Nc=i(pn);g(lo.$$.fragment,Nc),Nc.forEach(t),Wc.forEach(t),Mr=p(_a),hn=r(_a,"SPAN",{});var xc=i(hn);yr=s(xc,"Generation"),xc.forEach(t),_a.forEach(t),Ts=p(e),S=r(e,"P",{});var At=i(S);vr=s(At,`MusicGen is compatible with two generation modes: greedy and sampling. In practice, sampling leads to significantly
better results than greedy, thus we encourage sampling mode to be used where possible. Sampling is enabled by default,
and can be explicitly specified by setting `),un=r(At,"CODE",{});var zc=i(un);wr=s(zc,"do_sample=True"),zc.forEach(t),Tr=s(At," in the call to "),mn=r(At,"CODE",{});var Ic=i(mn);kr=s(Ic,"MusicgenForConditionalGeneration.generate()"),Ic.forEach(t),jr=s(At,`,
or by overriding the model\u2019s generation config (see below).`),At.forEach(t),ks=p(e),se=r(e,"H3",{class:!0});var ba=i(se);je=r(ba,"A",{id:!0,class:!0,href:!0});var Rc=i(je);fn=r(Rc,"SPAN",{});var Xc=i(fn);g(co.$$.fragment,Xc),Xc.forEach(t),Rc.forEach(t),Jr=p(ba),gn=r(ba,"SPAN",{});var Bc=i(gn);Cr=s(Bc,"Unconditional Generation"),Bc.forEach(t),ba.forEach(t),js=p(e),Je=r(e,"P",{});var Ma=i(Je);Gr=s(Ma,`The inputs for unconditional (or \u2018null\u2019) generation can be obtained through the method
`),_n=r(Ma,"CODE",{});var qc=i(_n);Zr=s(qc,"MusicgenForConditionalGeneration.get_unconditional_inputs()"),qc.forEach(t),Ur=s(Ma,":"),Ma.forEach(t),Js=p(e),g(po.$$.fragment,e),Cs=p(e),Ce=r(e,"P",{});var ya=i(Ce);Er=s(ya,"The audio outputs are a three-dimensional Torch tensor of shape "),bn=r(ya,"CODE",{});var Vc=i(bn);$r=s(Vc,"(batch_size, num_channels, sequence_length)"),Vc.forEach(t),Fr=s(ya,`. To listen
to the generated audio samples, you can either play them in an ipynb notebook:`),ya.forEach(t),Gs=p(e),g(ho.$$.fragment,e),Zs=p(e),D=r(e,"P",{});var Pt=i(D);Wr=s(Pt,"Or save them as a "),Mn=r(Pt,"CODE",{});var Yc=i(Mn);Nr=s(Yc,".wav"),Yc.forEach(t),xr=s(Pt," file using a third-party library, e.g. "),yn=r(Pt,"CODE",{});var Ac=i(yn);zr=s(Ac,"scipy"),Ac.forEach(t),Ir=s(Pt,":"),Pt.forEach(t),Us=p(e),g(uo.$$.fragment,e),Es=p(e),ae=r(e,"H3",{class:!0});var va=i(ae);Ge=r(va,"A",{id:!0,class:!0,href:!0});var Pc=i(Ge);vn=r(Pc,"SPAN",{});var Sc=i(vn);g(mo.$$.fragment,Sc),Sc.forEach(t),Pc.forEach(t),Rr=p(va),wn=r(va,"SPAN",{});var Dc=i(wn);Xr=s(Dc,"Text-Conditional Generation"),Dc.forEach(t),va.forEach(t),$s=p(e),Ze=r(e,"P",{});var wa=i(Ze);Br=s(wa,"The model can generate an audio sample conditioned on a text prompt through use of the "),gt=r(wa,"A",{href:!0});var Qc=i(gt);qr=s(Qc,"MusicgenProcessor"),Qc.forEach(t),Vr=s(wa,` to pre-process
the inputs:`),wa.forEach(t),Fs=p(e),g(fo.$$.fragment,e),Ws=p(e),z=r(e,"P",{});var eo=i(z);Yr=s(eo,"The "),Tn=r(eo,"CODE",{});var Hc=i(Tn);Ar=s(Hc,"guidance_scale"),Hc.forEach(t),Pr=s(eo,` is used in classifier free guidance (CFG), setting the weighting between the conditional logits
(which are predicted from the text prompts) and the unconditional logits (which are predicted from an unconditional or
\u2018null\u2019 prompt). Higher guidance scale encourages the model to generate samples that are more closely linked to the input
prompt, usually at the expense of poorer audio quality. CFG is enabled by setting `),kn=r(eo,"CODE",{});var Lc=i(kn);Sr=s(Lc,"guidance_scale > 1"),Lc.forEach(t),Dr=s(eo,`. For best results,
use `),jn=r(eo,"CODE",{});var Oc=i(jn);Qr=s(Oc,"guidance_scale=3"),Oc.forEach(t),Hr=s(eo," (default)."),eo.forEach(t),Ns=p(e),re=r(e,"H3",{class:!0});var Ta=i(re);Ue=r(Ta,"A",{id:!0,class:!0,href:!0});var Kc=i(Ue);Jn=r(Kc,"SPAN",{});var ep=i(Jn);g(go.$$.fragment,ep),ep.forEach(t),Kc.forEach(t),Lr=p(Ta),Cn=r(Ta,"SPAN",{});var op=i(Cn);Or=s(op,"Audio-Prompted Generation"),op.forEach(t),Ta.forEach(t),xs=p(e),Ee=r(e,"P",{});var ka=i(Ee);Kr=s(ka,"The same "),_t=r(ka,"A",{href:!0});var tp=i(_t);ei=s(tp,"MusicgenProcessor"),tp.forEach(t),oi=s(ka,` can be used to pre-process an audio prompt that is used for audio continuation. In the
following example, we load an audio file using the \u{1F917} Datasets library, which can be pip installed through the command
below:`),ka.forEach(t),zs=p(e),g(_o.$$.fragment,e),Is=p(e),g(bo.$$.fragment,e),Rs=p(e),Q=r(e,"P",{});var St=i(Q);ti=s(St,"For batched audio-prompted generation, the generated "),Gn=r(St,"CODE",{});var np=i(Gn);ni=s(np,"audio_values"),np.forEach(t),si=s(St,` can be post-processed to remove padding by using the
`),bt=r(St,"A",{href:!0});var sp=i(bt);ai=s(sp,"MusicgenProcessor"),sp.forEach(t),ri=s(St," class:"),St.forEach(t),Xs=p(e),g(Mo.$$.fragment,e),Bs=p(e),ie=r(e,"H3",{class:!0});var ja=i(ie);$e=r(ja,"A",{id:!0,class:!0,href:!0});var ap=i($e);Zn=r(ap,"SPAN",{});var rp=i(Zn);g(yo.$$.fragment,rp),rp.forEach(t),ap.forEach(t),ii=p(ja),Un=r(ja,"SPAN",{});var ip=i(Un);li=s(ip,"Generation Configuration"),ip.forEach(t),ja.forEach(t),qs=p(e),Mt=r(e,"P",{});var lp=i(Mt);di=s(lp,`The default parameters that control the generation process, such as sampling, guidance scale and number of generated
tokens, can be found in the model\u2019s generation config, and updated as desired:`),lp.forEach(t),Vs=p(e),g(vo.$$.fragment,e),Ys=p(e),I=r(e,"P",{});var oo=i(I);ci=s(oo,"Note that any arguments passed to the generate method will "),En=r(oo,"STRONG",{});var dp=i(En);pi=s(dp,"supersede"),dp.forEach(t),hi=s(oo,` those in the generation config, so setting
`),$n=r(oo,"CODE",{});var cp=i($n);ui=s(cp,"do_sample=False"),cp.forEach(t),mi=s(oo," in the call to generate will supersede the setting of "),Fn=r(oo,"CODE",{});var pp=i(Fn);fi=s(pp,"model.generation_config.do_sample"),pp.forEach(t),gi=s(oo,` in the
generation config.`),oo.forEach(t),As=p(e),le=r(e,"H2",{class:!0});var Ja=i(le);Fe=r(Ja,"A",{id:!0,class:!0,href:!0});var hp=i(Fe);Wn=r(hp,"SPAN",{});var up=i(Wn);g(wo.$$.fragment,up),up.forEach(t),hp.forEach(t),_i=p(Ja),Nn=r(Ja,"SPAN",{});var mp=i(Nn);bi=s(mp,"Model Structure"),mp.forEach(t),Ja.forEach(t),Ps=p(e),yt=r(e,"P",{});var fp=i(yt);Mi=s(fp,"The MusicGen model can be de-composed into three distinct stages:"),fp.forEach(t),Ss=p(e),H=r(e,"OL",{});var Dt=i(H);xn=r(Dt,"LI",{});var gp=i(xn);yi=s(gp,"Text encoder: maps the text inputs to a sequence of hidden-state representations. The pre-trained MusicGen models use a frozen text encoder from either T5 or Flan-T5"),gp.forEach(t),vi=p(Dt),zn=r(Dt,"LI",{});var _p=i(zn);wi=s(_p,"MusicGen decoder: a language model (LM) that auto-regressively generates audio tokens (or codes) conditional on the encoder hidden-state representations"),_p.forEach(t),Ti=p(Dt),In=r(Dt,"LI",{});var bp=i(In);ki=s(bp,"Audio encoder/decoder: used to encode an audio prompt to use as prompt tokens, and recover the audio waveform from the audio tokens predicted by the decoder"),bp.forEach(t),Dt.forEach(t),Ds=p(e),L=r(e,"P",{});var Qt=i(L);ji=s(Qt,"Thus, the MusicGen model can either be used as a standalone decoder model, corresponding to the class "),vt=r(Qt,"A",{href:!0});var Mp=i(vt);Ji=s(Mp,"MusicgenForCausalLM"),Mp.forEach(t),Ci=s(Qt,`,
or as a composite model that includes the text encoder and audio encoder/decoder, corresponding to the class
`),wt=r(Qt,"A",{href:!0});var yp=i(wt);Gi=s(yp,"MusicgenForConditionalGeneration"),yp.forEach(t),Zi=s(Qt,"."),Qt.forEach(t),Qs=p(e),O=r(e,"P",{});var Ht=i(O);Ui=s(Ht,"Since the text encoder and audio encoder/decoder models are frozen during training, the MusicGen decoder "),Tt=r(Ht,"A",{href:!0});var vp=i(Tt);Ei=s(vp,"MusicgenForCausalLM"),vp.forEach(t),$i=s(Ht,`
can be trained standalone on a dataset of encoder hidden-states and audio codes. For inference, the trained decoder can
be combined with the frozen text encoder and audio encoder/decoders to recover the composite `),kt=r(Ht,"A",{href:!0});var wp=i(kt);Fi=s(wp,"MusicgenForConditionalGeneration"),wp.forEach(t),Wi=s(Ht,`
model.`),Ht.forEach(t),Hs=p(e),We=r(e,"P",{});var Ca=i(We);Ni=s(Ca,"Below, we demonstrate how to construct the composite "),jt=r(Ca,"A",{href:!0});var Tp=i(jt);xi=s(Tp,"MusicgenForConditionalGeneration"),Tp.forEach(t),zi=s(Ca,` model from its three constituent
parts, as would typically be done following training of the MusicGen decoder LM:`),Ca.forEach(t),Ls=p(e),g(To.$$.fragment,e),Os=p(e),Ne=r(e,"P",{});var Ga=i(Ne);Ii=s(Ga,`If only the decoder needs to be loaded from the pre-trained checkpoint for the composite model, it can be loaded by first
specifying the correct config, or be accessed through the `),Rn=r(Ga,"CODE",{});var kp=i(Rn);Ri=s(kp,".decoder"),kp.forEach(t),Xi=s(Ga," attribute of the composite model:"),Ga.forEach(t),Ks=p(e),g(ko.$$.fragment,e),ea=p(e),Jt=r(e,"P",{});var jp=i(Jt);Bi=s(jp,"Tips:"),jp.forEach(t),oa=p(e),xe=r(e,"UL",{});var Za=i(xe);Xn=r(Za,"LI",{});var Jp=i(Xn);qi=s(Jp,"MusicGen is trained on the 32kHz checkpoint of Encodec. You should ensure you use a compatible version of the Encodec model."),Jp.forEach(t),Vi=p(Za),ze=r(Za,"LI",{});var ms=i(ze);Yi=s(ms,"Sampling mode tends to deliver better results than greedy - you can toggle sampling with the variable "),Bn=r(ms,"CODE",{});var Cp=i(Bn);Ai=s(Cp,"do_sample"),Cp.forEach(t),Pi=s(ms," in the call to "),qn=r(ms,"CODE",{});var Gp=i(qn);Si=s(Gp,"MusicgenForConditionalGeneration.generate()"),Gp.forEach(t),ms.forEach(t),Za.forEach(t),ta=p(e),de=r(e,"H2",{class:!0});var Ua=i(de);Ie=r(Ua,"A",{id:!0,class:!0,href:!0});var Zp=i(Ie);Vn=r(Zp,"SPAN",{});var Up=i(Vn);g(jo.$$.fragment,Up),Up.forEach(t),Zp.forEach(t),Di=p(Ua),Yn=r(Ua,"SPAN",{});var Ep=i(Yn);Qi=s(Ep,"MusicgenDecoderConfig"),Ep.forEach(t),Ua.forEach(t),na=p(e),A=r(e,"DIV",{class:!0});var Lt=i(A);g(Jo.$$.fragment,Lt),Hi=p(Lt),ce=r(Lt,"P",{});var Ot=i(ce);Li=s(Ot,"This is the configuration class to store the configuration of an "),An=r(Ot,"CODE",{});var $p=i(An);Oi=s($p,"MusicgenDecoder"),$p.forEach(t),Ki=s(Ot,`. It is used to instantiate a
MusicGen decoder according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the MusicGen
`),Co=r(Ot,"A",{href:!0,rel:!0});var Fp=i(Co);el=s(Fp,"facebook/musicgen-small"),Fp.forEach(t),ol=s(Ot," architecture."),Ot.forEach(t),tl=p(Lt),pe=r(Lt,"P",{});var Kt=i(pe);nl=s(Kt,"Configuration objects inherit from "),Ct=r(Kt,"A",{href:!0});var Wp=i(Ct);sl=s(Wp,"PretrainedConfig"),Wp.forEach(t),al=s(Kt,` and can be used to control the model outputs. Read the
documentation from `),Gt=r(Kt,"A",{href:!0});var Np=i(Gt);rl=s(Np,"PretrainedConfig"),Np.forEach(t),il=s(Kt," for more information."),Kt.forEach(t),Lt.forEach(t),sa=p(e),he=r(e,"H2",{class:!0});var Ea=i(he);Re=r(Ea,"A",{id:!0,class:!0,href:!0});var xp=i(Re);Pn=r(xp,"SPAN",{});var zp=i(Pn);g(Go.$$.fragment,zp),zp.forEach(t),xp.forEach(t),ll=p(Ea),Sn=r(Ea,"SPAN",{});var Ip=i(Sn);dl=s(Ip,"MusicgenConfig"),Ip.forEach(t),Ea.forEach(t),aa=p(e),J=r(e,"DIV",{class:!0});var X=i(J);g(Zo.$$.fragment,X),cl=p(X),Uo=r(X,"P",{});var $a=i(Uo);pl=s($a,"This is the configuration class to store the configuration of a "),Zt=r($a,"A",{href:!0});var Rp=i(Zt);hl=s(Rp,"MusicgenModel"),Rp.forEach(t),ul=s($a,`. It is used to instantiate a
MusicGen model according to the specified arguments, defining the text encoder, audio encoder and MusicGen decoder
configs.`),$a.forEach(t),ml=p(X),ue=r(X,"P",{});var en=i(ue);fl=s(en,"Configuration objects inherit from "),Ut=r(en,"A",{href:!0});var Xp=i(Ut);gl=s(Xp,"PretrainedConfig"),Xp.forEach(t),_l=s(en,` and can be used to control the model outputs. Read the
documentation from `),Et=r(en,"A",{href:!0});var Bp=i(Et);bl=s(Bp,"PretrainedConfig"),Bp.forEach(t),Ml=s(en," for more information."),en.forEach(t),yl=p(X),g(Xe.$$.fragment,X),vl=p(X),Be=r(X,"DIV",{class:!0});var Fa=i(Be);g(Eo.$$.fragment,Fa),wl=p(Fa),$o=r(Fa,"P",{});var Wa=i($o);Tl=s(Wa,"Instantiate a "),$t=r(Wa,"A",{href:!0});var qp=i($t);kl=s(qp,"MusicgenConfig"),qp.forEach(t),jl=s(Wa,` (or a derived class) from text encoder, audio encoder and decoder
configurations.`),Wa.forEach(t),Fa.forEach(t),Jl=p(X),qe=r(X,"DIV",{class:!0});var Na=i(qe);g(Fo.$$.fragment,Na),Cl=p(Na),Wo=r(Na,"P",{});var xa=i(Wo);Gl=s(xa,"Serializes this instance to a Python dictionary. Override the default "),Ft=r(xa,"A",{href:!0});var Vp=i(Ft);Zl=s(Vp,"to_dict()"),Vp.forEach(t),Ul=s(xa,"."),xa.forEach(t),Na.forEach(t),X.forEach(t),ra=p(e),me=r(e,"H2",{class:!0});var za=i(me);Ve=r(za,"A",{id:!0,class:!0,href:!0});var Yp=i(Ve);Dn=r(Yp,"SPAN",{});var Ap=i(Dn);g(No.$$.fragment,Ap),Ap.forEach(t),Yp.forEach(t),El=p(za),Qn=r(za,"SPAN",{});var Pp=i(Qn);$l=s(Pp,"MusicgenProcessor"),Pp.forEach(t),za.forEach(t),ia=p(e),U=r(e,"DIV",{class:!0});var oe=i(U);g(xo.$$.fragment,oe),Fl=p(oe),Hn=r(oe,"P",{});var Sp=i(Hn);Wl=s(Sp,`Constructs a MusicGen processor which wraps an EnCodec feature extractor and a T5 tokenizer into a single processor
class.`),Sp.forEach(t),Nl=p(oe),$=r(oe,"P",{});var P=i($);Wt=r(P,"A",{href:!0});var Dp=i(Wt);xl=s(Dp,"MusicgenProcessor"),Dp.forEach(t),zl=s(P," offers all the functionalities of "),Nt=r(P,"A",{href:!0});var Qp=i(Nt);Il=s(Qp,"EncodecFeatureExtractor"),Qp.forEach(t),Rl=s(P," and "),Ln=r(P,"CODE",{});var Hp=i(Ln);Xl=s(Hp,"TTokenizer"),Hp.forEach(t),Bl=s(P,`. See
`),On=r(P,"CODE",{});var Lp=i(On);ql=s(Lp,"__call__()"),Lp.forEach(t),Vl=s(P," and "),xt=r(P,"A",{href:!0});var Op=i(xt);Yl=s(Op,"decode()"),Op.forEach(t),Al=s(P," for more information."),P.forEach(t),Pl=p(oe),Ye=r(oe,"DIV",{class:!0});var Ia=i(Ye);g(zo.$$.fragment,Ia),Sl=p(Ia),Io=r(Ia,"P",{});var Ra=i(Io);Dl=s(Ra,`This method is used to decode either batches of audio outputs from the MusicGen model, or batches of token ids
from the tokenizer. In the case of decoding token ids, this method forwards all its arguments to T5Tokenizer\u2019s
`),zt=r(Ra,"A",{href:!0});var Kp=i(zt);Ql=s(Kp,"batch_decode()"),Kp.forEach(t),Hl=s(Ra,". Please refer to the docstring of this method for more information."),Ra.forEach(t),Ia.forEach(t),Ll=p(oe),Ae=r(oe,"DIV",{class:!0});var Xa=i(Ae);g(Ro.$$.fragment,Xa),Ol=p(Xa),Xo=r(Xa,"P",{});var Ba=i(Xo);Kl=s(Ba,"This method forwards all its arguments to T5Tokenizer\u2019s "),It=r(Ba,"A",{href:!0});var eh=i(It);ed=s(eh,"decode()"),eh.forEach(t),od=s(Ba,`. Please refer to the
docstring of this method for more information.`),Ba.forEach(t),Xa.forEach(t),oe.forEach(t),la=p(e),fe=r(e,"H2",{class:!0});var qa=i(fe);Pe=r(qa,"A",{id:!0,class:!0,href:!0});var oh=i(Pe);Kn=r(oh,"SPAN",{});var th=i(Kn);g(Bo.$$.fragment,th),th.forEach(t),oh.forEach(t),td=p(qa),es=r(qa,"SPAN",{});var nh=i(es);nd=s(nh,"MusicgenModel"),nh.forEach(t),qa.forEach(t),da=p(e),C=r(e,"DIV",{class:!0});var B=i(C);g(qo.$$.fragment,B),sd=p(B),os=r(B,"P",{});var sh=i(os);ad=s(sh,"The bare Musicgen decoder model outputting raw hidden-states without any specific head on top."),sh.forEach(t),rd=p(B),Vo=r(B,"P",{});var Va=i(Vo);id=s(Va,"The Musicgen model was proposed in "),Yo=r(Va,"A",{href:!0,rel:!0});var ah=i(Yo);ld=s(ah,"Simple and Controllable Music Generation"),ah.forEach(t),dd=s(Va,` by
Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre D\xE9fossez. It is an
encoder decoder transformer trained on the task of conditional music generation`),Va.forEach(t),cd=p(B),Ao=r(B,"P",{});var Ya=i(Ao);pd=s(Ya,"This model inherits from "),Rt=r(Ya,"A",{href:!0});var rh=i(Rt);hd=s(rh,"PreTrainedModel"),rh.forEach(t),ud=s(Ya,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ya.forEach(t),md=p(B),Po=r(B,"P",{});var Aa=i(Po);fd=s(Aa,"This model is also a PyTorch "),So=r(Aa,"A",{href:!0,rel:!0});var ih=i(So);gd=s(ih,"torch.nn.Module"),ih.forEach(t),_d=s(Aa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Aa.forEach(t),bd=p(B),K=r(B,"DIV",{class:!0});var on=i(K);g(Do.$$.fragment,on),Md=p(on),ge=r(on,"P",{});var tn=i(ge);yd=s(tn,"The "),Xt=r(tn,"A",{href:!0});var lh=i(Xt);vd=s(lh,"MusicgenModel"),lh.forEach(t),wd=s(tn," forward method, overrides the "),ts=r(tn,"CODE",{});var dh=i(ts);Td=s(dh,"__call__"),dh.forEach(t),kd=s(tn," special method."),tn.forEach(t),jd=p(on),g(Se.$$.fragment,on),on.forEach(t),B.forEach(t),ca=p(e),_e=r(e,"H2",{class:!0});var Pa=i(_e);De=r(Pa,"A",{id:!0,class:!0,href:!0});var ch=i(De);ns=r(ch,"SPAN",{});var ph=i(ns);g(Qo.$$.fragment,ph),ph.forEach(t),ch.forEach(t),Jd=p(Pa),ss=r(Pa,"SPAN",{});var hh=i(ss);Cd=s(hh,"MusicgenForCausalLM"),hh.forEach(t),Pa.forEach(t),pa=p(e),G=r(e,"DIV",{class:!0});var q=i(G);g(Ho.$$.fragment,q),Gd=p(q),as=r(q,"P",{});var uh=i(as);Zd=s(uh,"The MusicGen decoder model with a language modelling head on top."),uh.forEach(t),Ud=p(q),Lo=r(q,"P",{});var Sa=i(Lo);Ed=s(Sa,"The Musicgen model was proposed in "),Oo=r(Sa,"A",{href:!0,rel:!0});var mh=i(Oo);$d=s(mh,"Simple and Controllable Music Generation"),mh.forEach(t),Fd=s(Sa,` by
Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre D\xE9fossez. It is an
encoder decoder transformer trained on the task of conditional music generation`),Sa.forEach(t),Wd=p(q),Ko=r(q,"P",{});var Da=i(Ko);Nd=s(Da,"This model inherits from "),Bt=r(Da,"A",{href:!0});var fh=i(Bt);xd=s(fh,"PreTrainedModel"),fh.forEach(t),zd=s(Da,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Da.forEach(t),Id=p(q),et=r(q,"P",{});var Qa=i(et);Rd=s(Qa,"This model is also a PyTorch "),ot=r(Qa,"A",{href:!0,rel:!0});var gh=i(ot);Xd=s(gh,"torch.nn.Module"),gh.forEach(t),Bd=s(Qa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Qa.forEach(t),qd=p(q),ee=r(q,"DIV",{class:!0});var nn=i(ee);g(tt.$$.fragment,nn),Vd=p(nn),be=r(nn,"P",{});var sn=i(be);Yd=s(sn,"The "),qt=r(sn,"A",{href:!0});var _h=i(qt);Ad=s(_h,"MusicgenForCausalLM"),_h.forEach(t),Pd=s(sn," forward method, overrides the "),rs=r(sn,"CODE",{});var bh=i(rs);Sd=s(bh,"__call__"),bh.forEach(t),Dd=s(sn," special method."),sn.forEach(t),Qd=p(nn),g(Qe.$$.fragment,nn),nn.forEach(t),q.forEach(t),ha=p(e),Me=r(e,"H2",{class:!0});var Ha=i(Me);He=r(Ha,"A",{id:!0,class:!0,href:!0});var Mh=i(He);is=r(Mh,"SPAN",{});var yh=i(is);g(nt.$$.fragment,yh),yh.forEach(t),Mh.forEach(t),Hd=p(Ha),ls=r(Ha,"SPAN",{});var vh=i(ls);Ld=s(vh,"MusicgenForConditionalGeneration"),vh.forEach(t),Ha.forEach(t),ua=p(e),Z=r(e,"DIV",{class:!0});var V=i(Z);g(st.$$.fragment,V),Od=p(V),ds=r(V,"P",{});var wh=i(ds);Kd=s(wh,"The composite MusicGen model with a text encoder, audio encoder and Musicgen decoder,for music generation tasks with one or both of text and audio prompts."),wh.forEach(t),ec=p(V),at=r(V,"P",{});var La=i(at);oc=s(La,"The Musicgen model was proposed in "),rt=r(La,"A",{href:!0,rel:!0});var Th=i(rt);tc=s(Th,"Simple and Controllable Music Generation"),Th.forEach(t),nc=s(La,` by
Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre D\xE9fossez. It is an
encoder decoder transformer trained on the task of conditional music generation`),La.forEach(t),sc=p(V),it=r(V,"P",{});var Oa=i(it);ac=s(Oa,"This model inherits from "),Vt=r(Oa,"A",{href:!0});var kh=i(Vt);rc=s(kh,"PreTrainedModel"),kh.forEach(t),ic=s(Oa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Oa.forEach(t),lc=p(V),lt=r(V,"P",{});var Ka=i(lt);dc=s(Ka,"This model is also a PyTorch "),dt=r(Ka,"A",{href:!0,rel:!0});var jh=i(dt);cc=s(jh,"torch.nn.Module"),jh.forEach(t),pc=s(Ka,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ka.forEach(t),hc=p(V),R=r(V,"DIV",{class:!0});var to=i(R);g(ct.$$.fragment,to),uc=p(to),ye=r(to,"P",{});var an=i(ye);mc=s(an,"The "),Yt=r(an,"A",{href:!0});var Jh=i(Yt);fc=s(Jh,"MusicgenForConditionalGeneration"),Jh.forEach(t),gc=s(an," forward method, overrides the "),cs=r(an,"CODE",{});var Ch=i(cs);_c=s(Ch,"__call__"),Ch.forEach(t),bc=s(an," special method."),an.forEach(t),Mc=p(to),g(Le.$$.fragment,to),yc=p(to),g(Oe.$$.fragment,to),to.forEach(t),V.forEach(t),this.h()},h(){d(m,"name","hf:doc:metadata"),d(m,"content",JSON.stringify(Bh)),d(T,"id","musicgen"),d(T,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(T,"href","#musicgen"),d(w,"class","relative group"),d(ve,"id","overview"),d(ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(ve,"href","#overview"),d(te,"class","relative group"),d(so,"href","https://arxiv.org/abs/2306.05284"),d(so,"rel","nofollow"),d(ao,"href","https://huggingface.co/sanchit-gandhi"),d(ao,"rel","nofollow"),d(ro,"href","https://github.com/facebookresearch/audiocraft"),d(ro,"rel","nofollow"),d(io,"href","https://huggingface.co/models?sort=downloads&search=facebook%2Fmusicgen-"),d(io,"rel","nofollow"),d(ke,"id","generation"),d(ke,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(ke,"href","#generation"),d(ne,"class","relative group"),d(je,"id","unconditional-generation"),d(je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(je,"href","#unconditional-generation"),d(se,"class","relative group"),d(Ge,"id","textconditional-generation"),d(Ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Ge,"href","#textconditional-generation"),d(ae,"class","relative group"),d(gt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenProcessor"),d(Ue,"id","audioprompted-generation"),d(Ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Ue,"href","#audioprompted-generation"),d(re,"class","relative group"),d(_t,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenProcessor"),d(bt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenProcessor"),d($e,"id","generation-configuration"),d($e,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d($e,"href","#generation-configuration"),d(ie,"class","relative group"),d(Fe,"id","model-structure"),d(Fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Fe,"href","#model-structure"),d(le,"class","relative group"),d(vt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForCausalLM"),d(wt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(Tt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForCausalLM"),d(kt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(jt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(Ie,"id","transformers.MusicgenDecoderConfig"),d(Ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Ie,"href","#transformers.MusicgenDecoderConfig"),d(de,"class","relative group"),d(Co,"href","https://huggingface.co/facebook/musicgen-small"),d(Co,"rel","nofollow"),d(Ct,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(Gt,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Re,"id","transformers.MusicgenConfig"),d(Re,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Re,"href","#transformers.MusicgenConfig"),d(he,"class","relative group"),d(Zt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenModel"),d(Ut,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(Et,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),d($t,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenConfig"),d(Be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Ft,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig.to_dict"),d(qe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Ve,"id","transformers.MusicgenProcessor"),d(Ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Ve,"href","#transformers.MusicgenProcessor"),d(me,"class","relative group"),d(Wt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenProcessor"),d(Nt,"href","/docs/transformers/v4.31.0/en/model_doc/encodec#transformers.EncodecFeatureExtractor"),d(xt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenProcessor.decode"),d(zt,"href","/docs/transformers/v4.31.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.batch_decode"),d(Ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(It,"href","/docs/transformers/v4.31.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.decode"),d(Ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Pe,"id","transformers.MusicgenModel"),d(Pe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Pe,"href","#transformers.MusicgenModel"),d(fe,"class","relative group"),d(Yo,"href","https://arxiv.org/abs/2306.05284"),d(Yo,"rel","nofollow"),d(Rt,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),d(So,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(So,"rel","nofollow"),d(Xt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenModel"),d(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(De,"id","transformers.MusicgenForCausalLM"),d(De,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(De,"href","#transformers.MusicgenForCausalLM"),d(_e,"class","relative group"),d(Oo,"href","https://arxiv.org/abs/2306.05284"),d(Oo,"rel","nofollow"),d(Bt,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),d(ot,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(ot,"rel","nofollow"),d(qt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForCausalLM"),d(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(He,"id","transformers.MusicgenForConditionalGeneration"),d(He,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(He,"href","#transformers.MusicgenForConditionalGeneration"),d(Me,"class","relative group"),d(rt,"href","https://arxiv.org/abs/2306.05284"),d(rt,"rel","nofollow"),d(Vt,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),d(dt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(dt,"rel","nofollow"),d(Yt,"href","/docs/transformers/v4.31.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,l){o(document.head,m),h(e,j,l),h(e,w,l),o(w,T),o(T,k),_(u,k,null),o(w,v),o(w,E),o(E,er),h(e,fs,l),h(e,te,l),o(te,ve),o(ve,rn),_(no,rn,null),o(te,or),o(te,ln),o(ln,tr),h(e,gs,l),h(e,we,l),o(we,nr),o(we,so),o(so,sr),o(we,ar),h(e,_s,l),h(e,Te,l),o(Te,rr),o(Te,dn),o(dn,ir),o(Te,lr),h(e,bs,l),h(e,ut,l),o(ut,dr),h(e,Ms,l),h(e,mt,l),o(mt,cr),h(e,ys,l),h(e,ft,l),o(ft,cn),o(cn,pr),h(e,vs,l),h(e,x,l),o(x,hr),o(x,ao),o(ao,ur),o(x,mr),o(x,ro),o(ro,fr),o(x,gr),o(x,io),o(io,_r),o(x,br),h(e,ws,l),h(e,ne,l),o(ne,ke),o(ke,pn),_(lo,pn,null),o(ne,Mr),o(ne,hn),o(hn,yr),h(e,Ts,l),h(e,S,l),o(S,vr),o(S,un),o(un,wr),o(S,Tr),o(S,mn),o(mn,kr),o(S,jr),h(e,ks,l),h(e,se,l),o(se,je),o(je,fn),_(co,fn,null),o(se,Jr),o(se,gn),o(gn,Cr),h(e,js,l),h(e,Je,l),o(Je,Gr),o(Je,_n),o(_n,Zr),o(Je,Ur),h(e,Js,l),_(po,e,l),h(e,Cs,l),h(e,Ce,l),o(Ce,Er),o(Ce,bn),o(bn,$r),o(Ce,Fr),h(e,Gs,l),_(ho,e,l),h(e,Zs,l),h(e,D,l),o(D,Wr),o(D,Mn),o(Mn,Nr),o(D,xr),o(D,yn),o(yn,zr),o(D,Ir),h(e,Us,l),_(uo,e,l),h(e,Es,l),h(e,ae,l),o(ae,Ge),o(Ge,vn),_(mo,vn,null),o(ae,Rr),o(ae,wn),o(wn,Xr),h(e,$s,l),h(e,Ze,l),o(Ze,Br),o(Ze,gt),o(gt,qr),o(Ze,Vr),h(e,Fs,l),_(fo,e,l),h(e,Ws,l),h(e,z,l),o(z,Yr),o(z,Tn),o(Tn,Ar),o(z,Pr),o(z,kn),o(kn,Sr),o(z,Dr),o(z,jn),o(jn,Qr),o(z,Hr),h(e,Ns,l),h(e,re,l),o(re,Ue),o(Ue,Jn),_(go,Jn,null),o(re,Lr),o(re,Cn),o(Cn,Or),h(e,xs,l),h(e,Ee,l),o(Ee,Kr),o(Ee,_t),o(_t,ei),o(Ee,oi),h(e,zs,l),_(_o,e,l),h(e,Is,l),_(bo,e,l),h(e,Rs,l),h(e,Q,l),o(Q,ti),o(Q,Gn),o(Gn,ni),o(Q,si),o(Q,bt),o(bt,ai),o(Q,ri),h(e,Xs,l),_(Mo,e,l),h(e,Bs,l),h(e,ie,l),o(ie,$e),o($e,Zn),_(yo,Zn,null),o(ie,ii),o(ie,Un),o(Un,li),h(e,qs,l),h(e,Mt,l),o(Mt,di),h(e,Vs,l),_(vo,e,l),h(e,Ys,l),h(e,I,l),o(I,ci),o(I,En),o(En,pi),o(I,hi),o(I,$n),o($n,ui),o(I,mi),o(I,Fn),o(Fn,fi),o(I,gi),h(e,As,l),h(e,le,l),o(le,Fe),o(Fe,Wn),_(wo,Wn,null),o(le,_i),o(le,Nn),o(Nn,bi),h(e,Ps,l),h(e,yt,l),o(yt,Mi),h(e,Ss,l),h(e,H,l),o(H,xn),o(xn,yi),o(H,vi),o(H,zn),o(zn,wi),o(H,Ti),o(H,In),o(In,ki),h(e,Ds,l),h(e,L,l),o(L,ji),o(L,vt),o(vt,Ji),o(L,Ci),o(L,wt),o(wt,Gi),o(L,Zi),h(e,Qs,l),h(e,O,l),o(O,Ui),o(O,Tt),o(Tt,Ei),o(O,$i),o(O,kt),o(kt,Fi),o(O,Wi),h(e,Hs,l),h(e,We,l),o(We,Ni),o(We,jt),o(jt,xi),o(We,zi),h(e,Ls,l),_(To,e,l),h(e,Os,l),h(e,Ne,l),o(Ne,Ii),o(Ne,Rn),o(Rn,Ri),o(Ne,Xi),h(e,Ks,l),_(ko,e,l),h(e,ea,l),h(e,Jt,l),o(Jt,Bi),h(e,oa,l),h(e,xe,l),o(xe,Xn),o(Xn,qi),o(xe,Vi),o(xe,ze),o(ze,Yi),o(ze,Bn),o(Bn,Ai),o(ze,Pi),o(ze,qn),o(qn,Si),h(e,ta,l),h(e,de,l),o(de,Ie),o(Ie,Vn),_(jo,Vn,null),o(de,Di),o(de,Yn),o(Yn,Qi),h(e,na,l),h(e,A,l),_(Jo,A,null),o(A,Hi),o(A,ce),o(ce,Li),o(ce,An),o(An,Oi),o(ce,Ki),o(ce,Co),o(Co,el),o(ce,ol),o(A,tl),o(A,pe),o(pe,nl),o(pe,Ct),o(Ct,sl),o(pe,al),o(pe,Gt),o(Gt,rl),o(pe,il),h(e,sa,l),h(e,he,l),o(he,Re),o(Re,Pn),_(Go,Pn,null),o(he,ll),o(he,Sn),o(Sn,dl),h(e,aa,l),h(e,J,l),_(Zo,J,null),o(J,cl),o(J,Uo),o(Uo,pl),o(Uo,Zt),o(Zt,hl),o(Uo,ul),o(J,ml),o(J,ue),o(ue,fl),o(ue,Ut),o(Ut,gl),o(ue,_l),o(ue,Et),o(Et,bl),o(ue,Ml),o(J,yl),_(Xe,J,null),o(J,vl),o(J,Be),_(Eo,Be,null),o(Be,wl),o(Be,$o),o($o,Tl),o($o,$t),o($t,kl),o($o,jl),o(J,Jl),o(J,qe),_(Fo,qe,null),o(qe,Cl),o(qe,Wo),o(Wo,Gl),o(Wo,Ft),o(Ft,Zl),o(Wo,Ul),h(e,ra,l),h(e,me,l),o(me,Ve),o(Ve,Dn),_(No,Dn,null),o(me,El),o(me,Qn),o(Qn,$l),h(e,ia,l),h(e,U,l),_(xo,U,null),o(U,Fl),o(U,Hn),o(Hn,Wl),o(U,Nl),o(U,$),o($,Wt),o(Wt,xl),o($,zl),o($,Nt),o(Nt,Il),o($,Rl),o($,Ln),o(Ln,Xl),o($,Bl),o($,On),o(On,ql),o($,Vl),o($,xt),o(xt,Yl),o($,Al),o(U,Pl),o(U,Ye),_(zo,Ye,null),o(Ye,Sl),o(Ye,Io),o(Io,Dl),o(Io,zt),o(zt,Ql),o(Io,Hl),o(U,Ll),o(U,Ae),_(Ro,Ae,null),o(Ae,Ol),o(Ae,Xo),o(Xo,Kl),o(Xo,It),o(It,ed),o(Xo,od),h(e,la,l),h(e,fe,l),o(fe,Pe),o(Pe,Kn),_(Bo,Kn,null),o(fe,td),o(fe,es),o(es,nd),h(e,da,l),h(e,C,l),_(qo,C,null),o(C,sd),o(C,os),o(os,ad),o(C,rd),o(C,Vo),o(Vo,id),o(Vo,Yo),o(Yo,ld),o(Vo,dd),o(C,cd),o(C,Ao),o(Ao,pd),o(Ao,Rt),o(Rt,hd),o(Ao,ud),o(C,md),o(C,Po),o(Po,fd),o(Po,So),o(So,gd),o(Po,_d),o(C,bd),o(C,K),_(Do,K,null),o(K,Md),o(K,ge),o(ge,yd),o(ge,Xt),o(Xt,vd),o(ge,wd),o(ge,ts),o(ts,Td),o(ge,kd),o(K,jd),_(Se,K,null),h(e,ca,l),h(e,_e,l),o(_e,De),o(De,ns),_(Qo,ns,null),o(_e,Jd),o(_e,ss),o(ss,Cd),h(e,pa,l),h(e,G,l),_(Ho,G,null),o(G,Gd),o(G,as),o(as,Zd),o(G,Ud),o(G,Lo),o(Lo,Ed),o(Lo,Oo),o(Oo,$d),o(Lo,Fd),o(G,Wd),o(G,Ko),o(Ko,Nd),o(Ko,Bt),o(Bt,xd),o(Ko,zd),o(G,Id),o(G,et),o(et,Rd),o(et,ot),o(ot,Xd),o(et,Bd),o(G,qd),o(G,ee),_(tt,ee,null),o(ee,Vd),o(ee,be),o(be,Yd),o(be,qt),o(qt,Ad),o(be,Pd),o(be,rs),o(rs,Sd),o(be,Dd),o(ee,Qd),_(Qe,ee,null),h(e,ha,l),h(e,Me,l),o(Me,He),o(He,is),_(nt,is,null),o(Me,Hd),o(Me,ls),o(ls,Ld),h(e,ua,l),h(e,Z,l),_(st,Z,null),o(Z,Od),o(Z,ds),o(ds,Kd),o(Z,ec),o(Z,at),o(at,oc),o(at,rt),o(rt,tc),o(at,nc),o(Z,sc),o(Z,it),o(it,ac),o(it,Vt),o(Vt,rc),o(it,ic),o(Z,lc),o(Z,lt),o(lt,dc),o(lt,dt),o(dt,cc),o(lt,pc),o(Z,hc),o(Z,R),_(ct,R,null),o(R,uc),o(R,ye),o(ye,mc),o(ye,Yt),o(Yt,fc),o(ye,gc),o(ye,cs),o(cs,_c),o(ye,bc),o(R,Mc),_(Le,R,null),o(R,yc),_(Oe,R,null),ma=!0},p(e,[l]){const pt={};l&2&&(pt.$$scope={dirty:l,ctx:e}),Xe.$set(pt);const ps={};l&2&&(ps.$$scope={dirty:l,ctx:e}),Se.$set(ps);const hs={};l&2&&(hs.$$scope={dirty:l,ctx:e}),Qe.$set(hs);const us={};l&2&&(us.$$scope={dirty:l,ctx:e}),Le.$set(us);const ht={};l&2&&(ht.$$scope={dirty:l,ctx:e}),Oe.$set(ht)},i(e){ma||(b(u.$$.fragment,e),b(no.$$.fragment,e),b(lo.$$.fragment,e),b(co.$$.fragment,e),b(po.$$.fragment,e),b(ho.$$.fragment,e),b(uo.$$.fragment,e),b(mo.$$.fragment,e),b(fo.$$.fragment,e),b(go.$$.fragment,e),b(_o.$$.fragment,e),b(bo.$$.fragment,e),b(Mo.$$.fragment,e),b(yo.$$.fragment,e),b(vo.$$.fragment,e),b(wo.$$.fragment,e),b(To.$$.fragment,e),b(ko.$$.fragment,e),b(jo.$$.fragment,e),b(Jo.$$.fragment,e),b(Go.$$.fragment,e),b(Zo.$$.fragment,e),b(Xe.$$.fragment,e),b(Eo.$$.fragment,e),b(Fo.$$.fragment,e),b(No.$$.fragment,e),b(xo.$$.fragment,e),b(zo.$$.fragment,e),b(Ro.$$.fragment,e),b(Bo.$$.fragment,e),b(qo.$$.fragment,e),b(Do.$$.fragment,e),b(Se.$$.fragment,e),b(Qo.$$.fragment,e),b(Ho.$$.fragment,e),b(tt.$$.fragment,e),b(Qe.$$.fragment,e),b(nt.$$.fragment,e),b(st.$$.fragment,e),b(ct.$$.fragment,e),b(Le.$$.fragment,e),b(Oe.$$.fragment,e),ma=!0)},o(e){M(u.$$.fragment,e),M(no.$$.fragment,e),M(lo.$$.fragment,e),M(co.$$.fragment,e),M(po.$$.fragment,e),M(ho.$$.fragment,e),M(uo.$$.fragment,e),M(mo.$$.fragment,e),M(fo.$$.fragment,e),M(go.$$.fragment,e),M(_o.$$.fragment,e),M(bo.$$.fragment,e),M(Mo.$$.fragment,e),M(yo.$$.fragment,e),M(vo.$$.fragment,e),M(wo.$$.fragment,e),M(To.$$.fragment,e),M(ko.$$.fragment,e),M(jo.$$.fragment,e),M(Jo.$$.fragment,e),M(Go.$$.fragment,e),M(Zo.$$.fragment,e),M(Xe.$$.fragment,e),M(Eo.$$.fragment,e),M(Fo.$$.fragment,e),M(No.$$.fragment,e),M(xo.$$.fragment,e),M(zo.$$.fragment,e),M(Ro.$$.fragment,e),M(Bo.$$.fragment,e),M(qo.$$.fragment,e),M(Do.$$.fragment,e),M(Se.$$.fragment,e),M(Qo.$$.fragment,e),M(Ho.$$.fragment,e),M(tt.$$.fragment,e),M(Qe.$$.fragment,e),M(nt.$$.fragment,e),M(st.$$.fragment,e),M(ct.$$.fragment,e),M(Le.$$.fragment,e),M(Oe.$$.fragment,e),ma=!1},d(e){t(m),e&&t(j),e&&t(w),y(u),e&&t(fs),e&&t(te),y(no),e&&t(gs),e&&t(we),e&&t(_s),e&&t(Te),e&&t(bs),e&&t(ut),e&&t(Ms),e&&t(mt),e&&t(ys),e&&t(ft),e&&t(vs),e&&t(x),e&&t(ws),e&&t(ne),y(lo),e&&t(Ts),e&&t(S),e&&t(ks),e&&t(se),y(co),e&&t(js),e&&t(Je),e&&t(Js),y(po,e),e&&t(Cs),e&&t(Ce),e&&t(Gs),y(ho,e),e&&t(Zs),e&&t(D),e&&t(Us),y(uo,e),e&&t(Es),e&&t(ae),y(mo),e&&t($s),e&&t(Ze),e&&t(Fs),y(fo,e),e&&t(Ws),e&&t(z),e&&t(Ns),e&&t(re),y(go),e&&t(xs),e&&t(Ee),e&&t(zs),y(_o,e),e&&t(Is),y(bo,e),e&&t(Rs),e&&t(Q),e&&t(Xs),y(Mo,e),e&&t(Bs),e&&t(ie),y(yo),e&&t(qs),e&&t(Mt),e&&t(Vs),y(vo,e),e&&t(Ys),e&&t(I),e&&t(As),e&&t(le),y(wo),e&&t(Ps),e&&t(yt),e&&t(Ss),e&&t(H),e&&t(Ds),e&&t(L),e&&t(Qs),e&&t(O),e&&t(Hs),e&&t(We),e&&t(Ls),y(To,e),e&&t(Os),e&&t(Ne),e&&t(Ks),y(ko,e),e&&t(ea),e&&t(Jt),e&&t(oa),e&&t(xe),e&&t(ta),e&&t(de),y(jo),e&&t(na),e&&t(A),y(Jo),e&&t(sa),e&&t(he),y(Go),e&&t(aa),e&&t(J),y(Zo),y(Xe),y(Eo),y(Fo),e&&t(ra),e&&t(me),y(No),e&&t(ia),e&&t(U),y(xo),y(zo),y(Ro),e&&t(la),e&&t(fe),y(Bo),e&&t(da),e&&t(C),y(qo),y(Do),y(Se),e&&t(ca),e&&t(_e),y(Qo),e&&t(pa),e&&t(G),y(Ho),y(tt),y(Qe),e&&t(ha),e&&t(Me),y(nt),e&&t(ua),e&&t(Z),y(st),y(ct),y(Le),y(Oe)}}}const Bh={local:"musicgen",sections:[{local:"overview",title:"Overview"},{local:"generation",sections:[{local:"unconditional-generation",title:"Unconditional Generation"},{local:"textconditional-generation",title:"Text-Conditional Generation"},{local:"audioprompted-generation",title:"Audio-Prompted Generation"},{local:"generation-configuration",title:"Generation Configuration"}],title:"Generation"},{local:"model-structure",title:"Model Structure"},{local:"transformers.MusicgenDecoderConfig",title:"MusicgenDecoderConfig"},{local:"transformers.MusicgenConfig",title:"MusicgenConfig"},{local:"transformers.MusicgenProcessor",title:"MusicgenProcessor"},{local:"transformers.MusicgenModel",title:"MusicgenModel"},{local:"transformers.MusicgenForCausalLM",title:"MusicgenForCausalLM"},{local:"transformers.MusicgenForConditionalGeneration",title:"MusicgenForConditionalGeneration"}],title:"MusicGen"};function qh(N){return Wh(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qh extends Uh{constructor(m){super();Eh(this,m,qh,Xh,$h,{})}}export{Qh as default,Bh as metadata};
