import{S as bh,i as Mh,s as yh,e as a,k as c,w as f,t as n,M as vh,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 _h}from"../../chunks/vendor-hf-doc-builder.js";import{T as cc}from"../../chunks/Tip-hf-doc-builder.js";import{D as q}from"../../chunks/Docstring-hf-doc-builder.js";import{C as V}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 Th(W){let m,j,w,T,k;return T=new V({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:_h,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 kh(W){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 jh(W){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 Jh(W){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 Ch(W){let m,j,w,T,k;return T=new V({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:_h,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 Gh(W){let m,j,w,T,k,u,v,E,Qa,ps,te,ve,tn,to,Da,nn,Ha,hs,we,La,no,Oa,Ka,us,Te,er,sn,or,tr,ms,ct,nr,fs,pt,sr,gs,ht,an,ar,_s,N,rr,so,ir,lr,ao,dr,cr,ro,pr,hr,bs,ne,ke,rn,io,ur,ln,mr,Ms,P,fr,dn,gr,_r,cn,br,Mr,ys,se,je,pn,lo,yr,hn,vr,vs,Je,wr,un,Tr,kr,ws,co,Ts,Ce,jr,mn,Jr,Cr,ks,po,js,S,Gr,fn,Zr,Ur,gn,Er,$r,Js,ho,Cs,ae,Ge,_n,uo,Fr,bn,Wr,Gs,Ze,Nr,ut,zr,xr,Zs,mo,Us,z,Ir,Mn,Rr,Xr,yn,Br,qr,vn,Vr,Yr,Es,re,Ue,wn,fo,Ar,Tn,Pr,$s,Ee,Sr,mt,Qr,Dr,Fs,go,Ws,_o,Ns,Q,Hr,kn,Lr,Or,ft,Kr,ei,zs,bo,xs,ie,$e,jn,Mo,oi,Jn,ti,Is,gt,ni,Rs,yo,Xs,x,si,Cn,ai,ri,Gn,ii,li,Zn,di,ci,Bs,le,Fe,Un,vo,pi,En,hi,qs,_t,ui,Vs,D,$n,mi,fi,Fn,gi,_i,Wn,bi,Ys,H,Mi,bt,yi,vi,Mt,wi,Ti,As,L,ki,yt,ji,Ji,vt,Ci,Gi,Ps,We,Zi,wt,Ui,Ei,Ss,wo,Qs,Ne,$i,Nn,Fi,Wi,Ds,To,Hs,Tt,Ni,Ls,ze,zn,zi,xi,xe,Ii,xn,Ri,Xi,In,Bi,Os,de,Ie,Rn,ko,qi,Xn,Vi,Ks,Y,jo,Yi,ce,Ai,Bn,Pi,Si,Jo,Qi,Di,Hi,pe,Li,kt,Oi,Ki,jt,el,ol,ea,he,Re,qn,Co,tl,Vn,nl,oa,Z,Go,sl,Zo,al,Jt,rl,il,ll,ue,dl,Ct,cl,pl,Gt,hl,ul,ml,Xe,fl,Be,Uo,gl,Eo,_l,Zt,bl,Ml,ta,me,qe,Yn,$o,yl,An,vl,na,U,Fo,wl,Pn,Tl,kl,$,Ut,jl,Jl,Et,Cl,Gl,Sn,Zl,Ul,Qn,El,$l,$t,Fl,Wl,Nl,Ve,Wo,zl,No,xl,Ft,Il,Rl,Xl,Ye,zo,Bl,xo,ql,Wt,Vl,Yl,sa,fe,Ae,Dn,Io,Al,Hn,Pl,aa,J,Ro,Sl,Ln,Ql,Dl,Xo,Hl,Bo,Ll,Ol,Kl,qo,ed,Nt,od,td,nd,Vo,sd,Yo,ad,rd,id,O,Ao,ld,ge,dd,zt,cd,pd,On,hd,ud,md,Pe,ra,_e,Se,Kn,Po,fd,es,gd,ia,C,So,_d,os,bd,Md,Qo,yd,Do,vd,wd,Td,Ho,kd,xt,jd,Jd,Cd,Lo,Gd,Oo,Zd,Ud,Ed,K,Ko,$d,be,Fd,It,Wd,Nd,ts,zd,xd,Id,Qe,la,Me,De,ns,et,Rd,ss,Xd,da,G,ot,Bd,as,qd,Vd,tt,Yd,nt,Ad,Pd,Sd,st,Qd,Rt,Dd,Hd,Ld,at,Od,rt,Kd,ec,oc,I,it,tc,ye,nc,Xt,sc,ac,rs,rc,ic,lc,He,dc,Le,ca;return u=new F({}),to=new F({}),io=new F({}),lo=new F({}),co=new V({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>)`}}),po=new V({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)`}}),ho=new V({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())`}}),uo=new F({}),mo=new V({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>)`}}),fo=new F({}),go=new V({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHBpcCUwQXBpcCUyMGluc3RhbGwlMjBkYXRhc2V0cyU1QmF1ZGlvJTVE",highlighted:`pip <span class="hljs-keyword">install</span> --upgrade pip
pip <span class="hljs-keyword">install</span> datasets[audio]`}}),_o=new V({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>)`}}),bo=new V({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)`}}),Mo=new F({}),yo=new V({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>`}}),vo=new F({}),wo=new V({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)`}}),To=new V({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`}}),ko=new F({}),jo=new q({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.32.0/src/transformers/models/musicgen/configuration_musicgen.py#L30"}}),Co=new F({}),Go=new q({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.32.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.32.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.32.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.32.0/src/transformers/models/musicgen/configuration_musicgen.py#L129"}}),Xe=new gh({props:{anchor:"transformers.MusicgenConfig.example",$$slots:{default:[Th]},$$scope:{ctx:W}}}),Uo=new q({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.32.0/src/transformers/models/musicgen/configuration_musicgen.py#L207",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenConfig"
>MusicgenConfig</a></p>
`}}),$o=new F({}),Fo=new q({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.32.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.32.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.32.0/src/transformers/models/musicgen/processing_musicgen.py#L26"}}),Wo=new q({props:{name:"batch_decode",anchor:"transformers.MusicgenProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/musicgen/processing_musicgen.py#L89"}}),zo=new q({props:{name:"decode",anchor:"transformers.MusicgenProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/models/musicgen/processing_musicgen.py#L107"}}),Io=new F({}),Ro=new q({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.32.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.32.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.32.0/src/transformers/models/musicgen/modeling_musicgen.py#L895"}}),Ao=new q({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.32.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>. See <a href="/docs/transformers/v4.32.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.32.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.32.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.32.0/src/transformers/models/musicgen/modeling_musicgen.py#L911"}}),Pe=new cc({props:{$$slots:{default:[kh]},$$scope:{ctx:W}}}),Po=new F({}),So=new q({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.32.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.32.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.32.0/src/transformers/models/musicgen/modeling_musicgen.py#L966"}}),Ko=new q({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.32.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>. See <a href="/docs/transformers/v4.32.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.32.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.32.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.32.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.32.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.32.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.32.0/src/transformers/models/musicgen/modeling_musicgen.py#L998"}}),Qe=new cc({props:{$$slots:{default:[jh]},$$scope:{ctx:W}}}),et=new F({}),ot=new q({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.32.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.32.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.32.0/src/transformers/models/musicgen/modeling_musicgen.py#L1449"}}),it=new q({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.32.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__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.32.0/en/model_doc/encodec#transformers.EncodecModel">EncodecModel</a>. See <a href="/docs/transformers/v4.32.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.32.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.32.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.32.0/src/transformers/models/musicgen/modeling_musicgen.py#L1805",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.32.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.32.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.32.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),He=new cc({props:{$$slots:{default:[Jh]},$$scope:{ctx:W}}}),Le=new gh({props:{anchor:"transformers.MusicgenForConditionalGeneration.forward.example",$$slots:{default:[Ch]},$$scope:{ctx:W}}}),{c(){m=a("meta"),j=c(),w=a("h1"),T=a("a"),k=a("span"),f(u.$$.fragment),v=c(),E=a("span"),Qa=n("MusicGen"),ps=c(),te=a("h2"),ve=a("a"),tn=a("span"),f(to.$$.fragment),Da=c(),nn=a("span"),Ha=n("Overview"),hs=c(),we=a("p"),La=n("The MusicGen model was proposed in the paper "),no=a("a"),Oa=n("Simple and Controllable Music Generation"),Ka=n(`
by Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi and Alexandre D\xE9fossez.`),us=c(),Te=a("p"),er=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 `),sn=a("em"),or=n("audio codes"),tr=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.`),ms=c(),ct=a("p"),nr=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.`),fs=c(),pt=a("p"),sr=n("The abstract from the paper is the following:"),gs=c(),ht=a("p"),an=a("em"),ar=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.`),_s=c(),N=a("p"),rr=n("This model was contributed by "),so=a("a"),ir=n("sanchit-gandhi"),lr=n(`. The original code can be found
`),ao=a("a"),dr=n("here"),cr=n(`. The pre-trained checkpoints can be found on the
`),ro=a("a"),pr=n("Hugging Face Hub"),hr=n("."),bs=c(),ne=a("h2"),ke=a("a"),rn=a("span"),f(io.$$.fragment),ur=c(),ln=a("span"),mr=n("Generation"),Ms=c(),P=a("p"),fr=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 `),dn=a("code"),gr=n("do_sample=True"),_r=n(" in the call to "),cn=a("code"),br=n("MusicgenForConditionalGeneration.generate()"),Mr=n(`,
or by overriding the model\u2019s generation config (see below).`),ys=c(),se=a("h3"),je=a("a"),pn=a("span"),f(lo.$$.fragment),yr=c(),hn=a("span"),vr=n("Unconditional Generation"),vs=c(),Je=a("p"),wr=n(`The inputs for unconditional (or \u2018null\u2019) generation can be obtained through the method
`),un=a("code"),Tr=n("MusicgenForConditionalGeneration.get_unconditional_inputs()"),kr=n(":"),ws=c(),f(co.$$.fragment),Ts=c(),Ce=a("p"),jr=n("The audio outputs are a three-dimensional Torch tensor of shape "),mn=a("code"),Jr=n("(batch_size, num_channels, sequence_length)"),Cr=n(`. To listen
to the generated audio samples, you can either play them in an ipynb notebook:`),ks=c(),f(po.$$.fragment),js=c(),S=a("p"),Gr=n("Or save them as a "),fn=a("code"),Zr=n(".wav"),Ur=n(" file using a third-party library, e.g. "),gn=a("code"),Er=n("scipy"),$r=n(":"),Js=c(),f(ho.$$.fragment),Cs=c(),ae=a("h3"),Ge=a("a"),_n=a("span"),f(uo.$$.fragment),Fr=c(),bn=a("span"),Wr=n("Text-Conditional Generation"),Gs=c(),Ze=a("p"),Nr=n("The model can generate an audio sample conditioned on a text prompt through use of the "),ut=a("a"),zr=n("MusicgenProcessor"),xr=n(` to pre-process
the inputs:`),Zs=c(),f(mo.$$.fragment),Us=c(),z=a("p"),Ir=n("The "),Mn=a("code"),Rr=n("guidance_scale"),Xr=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 `),yn=a("code"),Br=n("guidance_scale > 1"),qr=n(`. For best results,
use `),vn=a("code"),Vr=n("guidance_scale=3"),Yr=n(" (default)."),Es=c(),re=a("h3"),Ue=a("a"),wn=a("span"),f(fo.$$.fragment),Ar=c(),Tn=a("span"),Pr=n("Audio-Prompted Generation"),$s=c(),Ee=a("p"),Sr=n("The same "),mt=a("a"),Qr=n("MusicgenProcessor"),Dr=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:`),Fs=c(),f(go.$$.fragment),Ws=c(),f(_o.$$.fragment),Ns=c(),Q=a("p"),Hr=n("For batched audio-prompted generation, the generated "),kn=a("code"),Lr=n("audio_values"),Or=n(` can be post-processed to remove padding by using the
`),ft=a("a"),Kr=n("MusicgenProcessor"),ei=n(" class:"),zs=c(),f(bo.$$.fragment),xs=c(),ie=a("h3"),$e=a("a"),jn=a("span"),f(Mo.$$.fragment),oi=c(),Jn=a("span"),ti=n("Generation Configuration"),Is=c(),gt=a("p"),ni=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:`),Rs=c(),f(yo.$$.fragment),Xs=c(),x=a("p"),si=n("Note that any arguments passed to the generate method will "),Cn=a("strong"),ai=n("supersede"),ri=n(` those in the generation config, so setting
`),Gn=a("code"),ii=n("do_sample=False"),li=n(" in the call to generate will supersede the setting of "),Zn=a("code"),di=n("model.generation_config.do_sample"),ci=n(` in the
generation config.`),Bs=c(),le=a("h2"),Fe=a("a"),Un=a("span"),f(vo.$$.fragment),pi=c(),En=a("span"),hi=n("Model Structure"),qs=c(),_t=a("p"),ui=n("The MusicGen model can be de-composed into three distinct stages:"),Vs=c(),D=a("ol"),$n=a("li"),mi=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"),fi=c(),Fn=a("li"),gi=n("MusicGen decoder: a language model (LM) that auto-regressively generates audio tokens (or codes) conditional on the encoder hidden-state representations"),_i=c(),Wn=a("li"),bi=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"),Ys=c(),H=a("p"),Mi=n("Thus, the MusicGen model can either be used as a standalone decoder model, corresponding to the class "),bt=a("a"),yi=n("MusicgenForCausalLM"),vi=n(`,
or as a composite model that includes the text encoder and audio encoder/decoder, corresponding to the class
`),Mt=a("a"),wi=n("MusicgenForConditionalGeneration"),Ti=n("."),As=c(),L=a("p"),ki=n("Since the text encoder and audio encoder/decoder models are frozen during training, the MusicGen decoder "),yt=a("a"),ji=n("MusicgenForCausalLM"),Ji=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 `),vt=a("a"),Ci=n("MusicgenForConditionalGeneration"),Gi=n(`
model.`),Ps=c(),We=a("p"),Zi=n("Below, we demonstrate how to construct the composite "),wt=a("a"),Ui=n("MusicgenForConditionalGeneration"),Ei=n(` model from its three constituent
parts, as would typically be done following training of the MusicGen decoder LM:`),Ss=c(),f(wo.$$.fragment),Qs=c(),Ne=a("p"),$i=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 `),Nn=a("code"),Fi=n(".decoder"),Wi=n(" attribute of the composite model:"),Ds=c(),f(To.$$.fragment),Hs=c(),Tt=a("p"),Ni=n("Tips:"),Ls=c(),ze=a("ul"),zn=a("li"),zi=n("MusicGen is trained on the 32kHz checkpoint of Encodec. You should ensure you use a compatible version of the Encodec model."),xi=c(),xe=a("li"),Ii=n("Sampling mode tends to deliver better results than greedy - you can toggle sampling with the variable "),xn=a("code"),Ri=n("do_sample"),Xi=n(" in the call to "),In=a("code"),Bi=n("MusicgenForConditionalGeneration.generate()"),Os=c(),de=a("h2"),Ie=a("a"),Rn=a("span"),f(ko.$$.fragment),qi=c(),Xn=a("span"),Vi=n("MusicgenDecoderConfig"),Ks=c(),Y=a("div"),f(jo.$$.fragment),Yi=c(),ce=a("p"),Ai=n("This is the configuration class to store the configuration of an "),Bn=a("code"),Pi=n("MusicgenDecoder"),Si=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
`),Jo=a("a"),Qi=n("facebook/musicgen-small"),Di=n(" architecture."),Hi=c(),pe=a("p"),Li=n("Configuration objects inherit from "),kt=a("a"),Oi=n("PretrainedConfig"),Ki=n(` and can be used to control the model outputs. Read the
documentation from `),jt=a("a"),el=n("PretrainedConfig"),ol=n(" for more information."),ea=c(),he=a("h2"),Re=a("a"),qn=a("span"),f(Co.$$.fragment),tl=c(),Vn=a("span"),nl=n("MusicgenConfig"),oa=c(),Z=a("div"),f(Go.$$.fragment),sl=c(),Zo=a("p"),al=n("This is the configuration class to store the configuration of a "),Jt=a("a"),rl=n("MusicgenModel"),il=n(`. It is used to instantiate a
MusicGen model according to the specified arguments, defining the text encoder, audio encoder and MusicGen decoder
configs.`),ll=c(),ue=a("p"),dl=n("Configuration objects inherit from "),Ct=a("a"),cl=n("PretrainedConfig"),pl=n(` and can be used to control the model outputs. Read the
documentation from `),Gt=a("a"),hl=n("PretrainedConfig"),ul=n(" for more information."),ml=c(),f(Xe.$$.fragment),fl=c(),Be=a("div"),f(Uo.$$.fragment),gl=c(),Eo=a("p"),_l=n("Instantiate a "),Zt=a("a"),bl=n("MusicgenConfig"),Ml=n(` (or a derived class) from text encoder, audio encoder and decoder
configurations.`),ta=c(),me=a("h2"),qe=a("a"),Yn=a("span"),f($o.$$.fragment),yl=c(),An=a("span"),vl=n("MusicgenProcessor"),na=c(),U=a("div"),f(Fo.$$.fragment),wl=c(),Pn=a("p"),Tl=n(`Constructs a MusicGen processor which wraps an EnCodec feature extractor and a T5 tokenizer into a single processor
class.`),kl=c(),$=a("p"),Ut=a("a"),jl=n("MusicgenProcessor"),Jl=n(" offers all the functionalities of "),Et=a("a"),Cl=n("EncodecFeatureExtractor"),Gl=n(" and "),Sn=a("code"),Zl=n("TTokenizer"),Ul=n(`. See
`),Qn=a("code"),El=n("__call__()"),$l=n(" and "),$t=a("a"),Fl=n("decode()"),Wl=n(" for more information."),Nl=c(),Ve=a("div"),f(Wo.$$.fragment),zl=c(),No=a("p"),xl=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
`),Ft=a("a"),Il=n("batch_decode()"),Rl=n(". Please refer to the docstring of this method for more information."),Xl=c(),Ye=a("div"),f(zo.$$.fragment),Bl=c(),xo=a("p"),ql=n("This method forwards all its arguments to T5Tokenizer\u2019s "),Wt=a("a"),Vl=n("decode()"),Yl=n(`. Please refer to the
docstring of this method for more information.`),sa=c(),fe=a("h2"),Ae=a("a"),Dn=a("span"),f(Io.$$.fragment),Al=c(),Hn=a("span"),Pl=n("MusicgenModel"),aa=c(),J=a("div"),f(Ro.$$.fragment),Sl=c(),Ln=a("p"),Ql=n("The bare Musicgen decoder model outputting raw hidden-states without any specific head on top."),Dl=c(),Xo=a("p"),Hl=n("The Musicgen model was proposed in "),Bo=a("a"),Ll=n("Simple and Controllable Music Generation"),Ol=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`),Kl=c(),qo=a("p"),ed=n("This model inherits from "),Nt=a("a"),od=n("PreTrainedModel"),td=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.)`),nd=c(),Vo=a("p"),sd=n("This model is also a PyTorch "),Yo=a("a"),ad=n("torch.nn.Module"),rd=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),id=c(),O=a("div"),f(Ao.$$.fragment),ld=c(),ge=a("p"),dd=n("The "),zt=a("a"),cd=n("MusicgenModel"),pd=n(" forward method, overrides the "),On=a("code"),hd=n("__call__"),ud=n(" special method."),md=c(),f(Pe.$$.fragment),ra=c(),_e=a("h2"),Se=a("a"),Kn=a("span"),f(Po.$$.fragment),fd=c(),es=a("span"),gd=n("MusicgenForCausalLM"),ia=c(),C=a("div"),f(So.$$.fragment),_d=c(),os=a("p"),bd=n("The MusicGen decoder model with a language modelling head on top."),Md=c(),Qo=a("p"),yd=n("The Musicgen model was proposed in "),Do=a("a"),vd=n("Simple and Controllable Music Generation"),wd=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`),Td=c(),Ho=a("p"),kd=n("This model inherits from "),xt=a("a"),jd=n("PreTrainedModel"),Jd=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.)`),Cd=c(),Lo=a("p"),Gd=n("This model is also a PyTorch "),Oo=a("a"),Zd=n("torch.nn.Module"),Ud=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ed=c(),K=a("div"),f(Ko.$$.fragment),$d=c(),be=a("p"),Fd=n("The "),It=a("a"),Wd=n("MusicgenForCausalLM"),Nd=n(" forward method, overrides the "),ts=a("code"),zd=n("__call__"),xd=n(" special method."),Id=c(),f(Qe.$$.fragment),la=c(),Me=a("h2"),De=a("a"),ns=a("span"),f(et.$$.fragment),Rd=c(),ss=a("span"),Xd=n("MusicgenForConditionalGeneration"),da=c(),G=a("div"),f(ot.$$.fragment),Bd=c(),as=a("p"),qd=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."),Vd=c(),tt=a("p"),Yd=n("The Musicgen model was proposed in "),nt=a("a"),Ad=n("Simple and Controllable Music Generation"),Pd=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`),Sd=c(),st=a("p"),Qd=n("This model inherits from "),Rt=a("a"),Dd=n("PreTrainedModel"),Hd=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.)`),Ld=c(),at=a("p"),Od=n("This model is also a PyTorch "),rt=a("a"),Kd=n("torch.nn.Module"),ec=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),oc=c(),I=a("div"),f(it.$$.fragment),tc=c(),ye=a("p"),nc=n("The "),Xt=a("a"),sc=n("MusicgenForConditionalGeneration"),ac=n(" forward method, overrides the "),rs=a("code"),rc=n("__call__"),ic=n(" special method."),lc=c(),f(He.$$.fragment),dc=c(),f(Le.$$.fragment),this.h()},l(e){const l=vh('[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 lt=i(w);T=r(lt,"A",{id:!0,class:!0,href:!0});var is=i(T);k=r(is,"SPAN",{});var ls=i(k);g(u.$$.fragment,ls),ls.forEach(t),is.forEach(t),v=p(lt),E=r(lt,"SPAN",{});var ds=i(E);Qa=s(ds,"MusicGen"),ds.forEach(t),lt.forEach(t),ps=p(e),te=r(e,"H2",{class:!0});var dt=i(te);ve=r(dt,"A",{id:!0,class:!0,href:!0});var pc=i(ve);tn=r(pc,"SPAN",{});var hc=i(tn);g(to.$$.fragment,hc),hc.forEach(t),pc.forEach(t),Da=p(dt),nn=r(dt,"SPAN",{});var uc=i(nn);Ha=s(uc,"Overview"),uc.forEach(t),dt.forEach(t),hs=p(e),we=r(e,"P",{});var pa=i(we);La=s(pa,"The MusicGen model was proposed in the paper "),no=r(pa,"A",{href:!0,rel:!0});var mc=i(no);Oa=s(mc,"Simple and Controllable Music Generation"),mc.forEach(t),Ka=s(pa,`
by Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi and Alexandre D\xE9fossez.`),pa.forEach(t),us=p(e),Te=r(e,"P",{});var ha=i(Te);er=s(ha,`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 `),sn=r(ha,"EM",{});var fc=i(sn);or=s(fc,"audio codes"),fc.forEach(t),tr=s(ha,`,
conditioned on these hidden-states. These audio tokens are then decoded using an audio compression model, such as EnCodec,
to recover the audio waveform.`),ha.forEach(t),ms=p(e),ct=r(e,"P",{});var gc=i(ct);nr=s(gc,`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.`),gc.forEach(t),fs=p(e),pt=r(e,"P",{});var _c=i(pt);sr=s(_c,"The abstract from the paper is the following:"),_c.forEach(t),gs=p(e),ht=r(e,"P",{});var bc=i(ht);an=r(bc,"EM",{});var Mc=i(an);ar=s(Mc,`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.`),Mc.forEach(t),bc.forEach(t),_s=p(e),N=r(e,"P",{});var Oe=i(N);rr=s(Oe,"This model was contributed by "),so=r(Oe,"A",{href:!0,rel:!0});var yc=i(so);ir=s(yc,"sanchit-gandhi"),yc.forEach(t),lr=s(Oe,`. The original code can be found
`),ao=r(Oe,"A",{href:!0,rel:!0});var vc=i(ao);dr=s(vc,"here"),vc.forEach(t),cr=s(Oe,`. The pre-trained checkpoints can be found on the
`),ro=r(Oe,"A",{href:!0,rel:!0});var wc=i(ro);pr=s(wc,"Hugging Face Hub"),wc.forEach(t),hr=s(Oe,"."),Oe.forEach(t),bs=p(e),ne=r(e,"H2",{class:!0});var ua=i(ne);ke=r(ua,"A",{id:!0,class:!0,href:!0});var Tc=i(ke);rn=r(Tc,"SPAN",{});var kc=i(rn);g(io.$$.fragment,kc),kc.forEach(t),Tc.forEach(t),ur=p(ua),ln=r(ua,"SPAN",{});var jc=i(ln);mr=s(jc,"Generation"),jc.forEach(t),ua.forEach(t),Ms=p(e),P=r(e,"P",{});var Bt=i(P);fr=s(Bt,`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 `),dn=r(Bt,"CODE",{});var Jc=i(dn);gr=s(Jc,"do_sample=True"),Jc.forEach(t),_r=s(Bt," in the call to "),cn=r(Bt,"CODE",{});var Cc=i(cn);br=s(Cc,"MusicgenForConditionalGeneration.generate()"),Cc.forEach(t),Mr=s(Bt,`,
or by overriding the model\u2019s generation config (see below).`),Bt.forEach(t),ys=p(e),se=r(e,"H3",{class:!0});var ma=i(se);je=r(ma,"A",{id:!0,class:!0,href:!0});var Gc=i(je);pn=r(Gc,"SPAN",{});var Zc=i(pn);g(lo.$$.fragment,Zc),Zc.forEach(t),Gc.forEach(t),yr=p(ma),hn=r(ma,"SPAN",{});var Uc=i(hn);vr=s(Uc,"Unconditional Generation"),Uc.forEach(t),ma.forEach(t),vs=p(e),Je=r(e,"P",{});var fa=i(Je);wr=s(fa,`The inputs for unconditional (or \u2018null\u2019) generation can be obtained through the method
`),un=r(fa,"CODE",{});var Ec=i(un);Tr=s(Ec,"MusicgenForConditionalGeneration.get_unconditional_inputs()"),Ec.forEach(t),kr=s(fa,":"),fa.forEach(t),ws=p(e),g(co.$$.fragment,e),Ts=p(e),Ce=r(e,"P",{});var ga=i(Ce);jr=s(ga,"The audio outputs are a three-dimensional Torch tensor of shape "),mn=r(ga,"CODE",{});var $c=i(mn);Jr=s($c,"(batch_size, num_channels, sequence_length)"),$c.forEach(t),Cr=s(ga,`. To listen
to the generated audio samples, you can either play them in an ipynb notebook:`),ga.forEach(t),ks=p(e),g(po.$$.fragment,e),js=p(e),S=r(e,"P",{});var qt=i(S);Gr=s(qt,"Or save them as a "),fn=r(qt,"CODE",{});var Fc=i(fn);Zr=s(Fc,".wav"),Fc.forEach(t),Ur=s(qt," file using a third-party library, e.g. "),gn=r(qt,"CODE",{});var Wc=i(gn);Er=s(Wc,"scipy"),Wc.forEach(t),$r=s(qt,":"),qt.forEach(t),Js=p(e),g(ho.$$.fragment,e),Cs=p(e),ae=r(e,"H3",{class:!0});var _a=i(ae);Ge=r(_a,"A",{id:!0,class:!0,href:!0});var Nc=i(Ge);_n=r(Nc,"SPAN",{});var zc=i(_n);g(uo.$$.fragment,zc),zc.forEach(t),Nc.forEach(t),Fr=p(_a),bn=r(_a,"SPAN",{});var xc=i(bn);Wr=s(xc,"Text-Conditional Generation"),xc.forEach(t),_a.forEach(t),Gs=p(e),Ze=r(e,"P",{});var ba=i(Ze);Nr=s(ba,"The model can generate an audio sample conditioned on a text prompt through use of the "),ut=r(ba,"A",{href:!0});var Ic=i(ut);zr=s(Ic,"MusicgenProcessor"),Ic.forEach(t),xr=s(ba,` to pre-process
the inputs:`),ba.forEach(t),Zs=p(e),g(mo.$$.fragment,e),Us=p(e),z=r(e,"P",{});var Ke=i(z);Ir=s(Ke,"The "),Mn=r(Ke,"CODE",{});var Rc=i(Mn);Rr=s(Rc,"guidance_scale"),Rc.forEach(t),Xr=s(Ke,` 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 `),yn=r(Ke,"CODE",{});var Xc=i(yn);Br=s(Xc,"guidance_scale > 1"),Xc.forEach(t),qr=s(Ke,`. For best results,
use `),vn=r(Ke,"CODE",{});var Bc=i(vn);Vr=s(Bc,"guidance_scale=3"),Bc.forEach(t),Yr=s(Ke," (default)."),Ke.forEach(t),Es=p(e),re=r(e,"H3",{class:!0});var Ma=i(re);Ue=r(Ma,"A",{id:!0,class:!0,href:!0});var qc=i(Ue);wn=r(qc,"SPAN",{});var Vc=i(wn);g(fo.$$.fragment,Vc),Vc.forEach(t),qc.forEach(t),Ar=p(Ma),Tn=r(Ma,"SPAN",{});var Yc=i(Tn);Pr=s(Yc,"Audio-Prompted Generation"),Yc.forEach(t),Ma.forEach(t),$s=p(e),Ee=r(e,"P",{});var ya=i(Ee);Sr=s(ya,"The same "),mt=r(ya,"A",{href:!0});var Ac=i(mt);Qr=s(Ac,"MusicgenProcessor"),Ac.forEach(t),Dr=s(ya,` 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:`),ya.forEach(t),Fs=p(e),g(go.$$.fragment,e),Ws=p(e),g(_o.$$.fragment,e),Ns=p(e),Q=r(e,"P",{});var Vt=i(Q);Hr=s(Vt,"For batched audio-prompted generation, the generated "),kn=r(Vt,"CODE",{});var Pc=i(kn);Lr=s(Pc,"audio_values"),Pc.forEach(t),Or=s(Vt,` can be post-processed to remove padding by using the
`),ft=r(Vt,"A",{href:!0});var Sc=i(ft);Kr=s(Sc,"MusicgenProcessor"),Sc.forEach(t),ei=s(Vt," class:"),Vt.forEach(t),zs=p(e),g(bo.$$.fragment,e),xs=p(e),ie=r(e,"H3",{class:!0});var va=i(ie);$e=r(va,"A",{id:!0,class:!0,href:!0});var Qc=i($e);jn=r(Qc,"SPAN",{});var Dc=i(jn);g(Mo.$$.fragment,Dc),Dc.forEach(t),Qc.forEach(t),oi=p(va),Jn=r(va,"SPAN",{});var Hc=i(Jn);ti=s(Hc,"Generation Configuration"),Hc.forEach(t),va.forEach(t),Is=p(e),gt=r(e,"P",{});var Lc=i(gt);ni=s(Lc,`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:`),Lc.forEach(t),Rs=p(e),g(yo.$$.fragment,e),Xs=p(e),x=r(e,"P",{});var eo=i(x);si=s(eo,"Note that any arguments passed to the generate method will "),Cn=r(eo,"STRONG",{});var Oc=i(Cn);ai=s(Oc,"supersede"),Oc.forEach(t),ri=s(eo,` those in the generation config, so setting
`),Gn=r(eo,"CODE",{});var Kc=i(Gn);ii=s(Kc,"do_sample=False"),Kc.forEach(t),li=s(eo," in the call to generate will supersede the setting of "),Zn=r(eo,"CODE",{});var ep=i(Zn);di=s(ep,"model.generation_config.do_sample"),ep.forEach(t),ci=s(eo,` in the
generation config.`),eo.forEach(t),Bs=p(e),le=r(e,"H2",{class:!0});var wa=i(le);Fe=r(wa,"A",{id:!0,class:!0,href:!0});var op=i(Fe);Un=r(op,"SPAN",{});var tp=i(Un);g(vo.$$.fragment,tp),tp.forEach(t),op.forEach(t),pi=p(wa),En=r(wa,"SPAN",{});var np=i(En);hi=s(np,"Model Structure"),np.forEach(t),wa.forEach(t),qs=p(e),_t=r(e,"P",{});var sp=i(_t);ui=s(sp,"The MusicGen model can be de-composed into three distinct stages:"),sp.forEach(t),Vs=p(e),D=r(e,"OL",{});var Yt=i(D);$n=r(Yt,"LI",{});var ap=i($n);mi=s(ap,"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"),ap.forEach(t),fi=p(Yt),Fn=r(Yt,"LI",{});var rp=i(Fn);gi=s(rp,"MusicGen decoder: a language model (LM) that auto-regressively generates audio tokens (or codes) conditional on the encoder hidden-state representations"),rp.forEach(t),_i=p(Yt),Wn=r(Yt,"LI",{});var ip=i(Wn);bi=s(ip,"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"),ip.forEach(t),Yt.forEach(t),Ys=p(e),H=r(e,"P",{});var At=i(H);Mi=s(At,"Thus, the MusicGen model can either be used as a standalone decoder model, corresponding to the class "),bt=r(At,"A",{href:!0});var lp=i(bt);yi=s(lp,"MusicgenForCausalLM"),lp.forEach(t),vi=s(At,`,
or as a composite model that includes the text encoder and audio encoder/decoder, corresponding to the class
`),Mt=r(At,"A",{href:!0});var dp=i(Mt);wi=s(dp,"MusicgenForConditionalGeneration"),dp.forEach(t),Ti=s(At,"."),At.forEach(t),As=p(e),L=r(e,"P",{});var Pt=i(L);ki=s(Pt,"Since the text encoder and audio encoder/decoder models are frozen during training, the MusicGen decoder "),yt=r(Pt,"A",{href:!0});var cp=i(yt);ji=s(cp,"MusicgenForCausalLM"),cp.forEach(t),Ji=s(Pt,`
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 `),vt=r(Pt,"A",{href:!0});var pp=i(vt);Ci=s(pp,"MusicgenForConditionalGeneration"),pp.forEach(t),Gi=s(Pt,`
model.`),Pt.forEach(t),Ps=p(e),We=r(e,"P",{});var Ta=i(We);Zi=s(Ta,"Below, we demonstrate how to construct the composite "),wt=r(Ta,"A",{href:!0});var hp=i(wt);Ui=s(hp,"MusicgenForConditionalGeneration"),hp.forEach(t),Ei=s(Ta,` model from its three constituent
parts, as would typically be done following training of the MusicGen decoder LM:`),Ta.forEach(t),Ss=p(e),g(wo.$$.fragment,e),Qs=p(e),Ne=r(e,"P",{});var ka=i(Ne);$i=s(ka,`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 `),Nn=r(ka,"CODE",{});var up=i(Nn);Fi=s(up,".decoder"),up.forEach(t),Wi=s(ka," attribute of the composite model:"),ka.forEach(t),Ds=p(e),g(To.$$.fragment,e),Hs=p(e),Tt=r(e,"P",{});var mp=i(Tt);Ni=s(mp,"Tips:"),mp.forEach(t),Ls=p(e),ze=r(e,"UL",{});var ja=i(ze);zn=r(ja,"LI",{});var fp=i(zn);zi=s(fp,"MusicGen is trained on the 32kHz checkpoint of Encodec. You should ensure you use a compatible version of the Encodec model."),fp.forEach(t),xi=p(ja),xe=r(ja,"LI",{});var cs=i(xe);Ii=s(cs,"Sampling mode tends to deliver better results than greedy - you can toggle sampling with the variable "),xn=r(cs,"CODE",{});var gp=i(xn);Ri=s(gp,"do_sample"),gp.forEach(t),Xi=s(cs," in the call to "),In=r(cs,"CODE",{});var _p=i(In);Bi=s(_p,"MusicgenForConditionalGeneration.generate()"),_p.forEach(t),cs.forEach(t),ja.forEach(t),Os=p(e),de=r(e,"H2",{class:!0});var Ja=i(de);Ie=r(Ja,"A",{id:!0,class:!0,href:!0});var bp=i(Ie);Rn=r(bp,"SPAN",{});var Mp=i(Rn);g(ko.$$.fragment,Mp),Mp.forEach(t),bp.forEach(t),qi=p(Ja),Xn=r(Ja,"SPAN",{});var yp=i(Xn);Vi=s(yp,"MusicgenDecoderConfig"),yp.forEach(t),Ja.forEach(t),Ks=p(e),Y=r(e,"DIV",{class:!0});var St=i(Y);g(jo.$$.fragment,St),Yi=p(St),ce=r(St,"P",{});var Qt=i(ce);Ai=s(Qt,"This is the configuration class to store the configuration of an "),Bn=r(Qt,"CODE",{});var vp=i(Bn);Pi=s(vp,"MusicgenDecoder"),vp.forEach(t),Si=s(Qt,`. 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
`),Jo=r(Qt,"A",{href:!0,rel:!0});var wp=i(Jo);Qi=s(wp,"facebook/musicgen-small"),wp.forEach(t),Di=s(Qt," architecture."),Qt.forEach(t),Hi=p(St),pe=r(St,"P",{});var Dt=i(pe);Li=s(Dt,"Configuration objects inherit from "),kt=r(Dt,"A",{href:!0});var Tp=i(kt);Oi=s(Tp,"PretrainedConfig"),Tp.forEach(t),Ki=s(Dt,` and can be used to control the model outputs. Read the
documentation from `),jt=r(Dt,"A",{href:!0});var kp=i(jt);el=s(kp,"PretrainedConfig"),kp.forEach(t),ol=s(Dt," for more information."),Dt.forEach(t),St.forEach(t),ea=p(e),he=r(e,"H2",{class:!0});var Ca=i(he);Re=r(Ca,"A",{id:!0,class:!0,href:!0});var jp=i(Re);qn=r(jp,"SPAN",{});var Jp=i(qn);g(Co.$$.fragment,Jp),Jp.forEach(t),jp.forEach(t),tl=p(Ca),Vn=r(Ca,"SPAN",{});var Cp=i(Vn);nl=s(Cp,"MusicgenConfig"),Cp.forEach(t),Ca.forEach(t),oa=p(e),Z=r(e,"DIV",{class:!0});var ee=i(Z);g(Go.$$.fragment,ee),sl=p(ee),Zo=r(ee,"P",{});var Ga=i(Zo);al=s(Ga,"This is the configuration class to store the configuration of a "),Jt=r(Ga,"A",{href:!0});var Gp=i(Jt);rl=s(Gp,"MusicgenModel"),Gp.forEach(t),il=s(Ga,`. It is used to instantiate a
MusicGen model according to the specified arguments, defining the text encoder, audio encoder and MusicGen decoder
configs.`),Ga.forEach(t),ll=p(ee),ue=r(ee,"P",{});var Ht=i(ue);dl=s(Ht,"Configuration objects inherit from "),Ct=r(Ht,"A",{href:!0});var Zp=i(Ct);cl=s(Zp,"PretrainedConfig"),Zp.forEach(t),pl=s(Ht,` and can be used to control the model outputs. Read the
documentation from `),Gt=r(Ht,"A",{href:!0});var Up=i(Gt);hl=s(Up,"PretrainedConfig"),Up.forEach(t),ul=s(Ht," for more information."),Ht.forEach(t),ml=p(ee),g(Xe.$$.fragment,ee),fl=p(ee),Be=r(ee,"DIV",{class:!0});var Za=i(Be);g(Uo.$$.fragment,Za),gl=p(Za),Eo=r(Za,"P",{});var Ua=i(Eo);_l=s(Ua,"Instantiate a "),Zt=r(Ua,"A",{href:!0});var Ep=i(Zt);bl=s(Ep,"MusicgenConfig"),Ep.forEach(t),Ml=s(Ua,` (or a derived class) from text encoder, audio encoder and decoder
configurations.`),Ua.forEach(t),Za.forEach(t),ee.forEach(t),ta=p(e),me=r(e,"H2",{class:!0});var Ea=i(me);qe=r(Ea,"A",{id:!0,class:!0,href:!0});var $p=i(qe);Yn=r($p,"SPAN",{});var Fp=i(Yn);g($o.$$.fragment,Fp),Fp.forEach(t),$p.forEach(t),yl=p(Ea),An=r(Ea,"SPAN",{});var Wp=i(An);vl=s(Wp,"MusicgenProcessor"),Wp.forEach(t),Ea.forEach(t),na=p(e),U=r(e,"DIV",{class:!0});var oe=i(U);g(Fo.$$.fragment,oe),wl=p(oe),Pn=r(oe,"P",{});var Np=i(Pn);Tl=s(Np,`Constructs a MusicGen processor which wraps an EnCodec feature extractor and a T5 tokenizer into a single processor
class.`),Np.forEach(t),kl=p(oe),$=r(oe,"P",{});var A=i($);Ut=r(A,"A",{href:!0});var zp=i(Ut);jl=s(zp,"MusicgenProcessor"),zp.forEach(t),Jl=s(A," offers all the functionalities of "),Et=r(A,"A",{href:!0});var xp=i(Et);Cl=s(xp,"EncodecFeatureExtractor"),xp.forEach(t),Gl=s(A," and "),Sn=r(A,"CODE",{});var Ip=i(Sn);Zl=s(Ip,"TTokenizer"),Ip.forEach(t),Ul=s(A,`. See
`),Qn=r(A,"CODE",{});var Rp=i(Qn);El=s(Rp,"__call__()"),Rp.forEach(t),$l=s(A," and "),$t=r(A,"A",{href:!0});var Xp=i($t);Fl=s(Xp,"decode()"),Xp.forEach(t),Wl=s(A," for more information."),A.forEach(t),Nl=p(oe),Ve=r(oe,"DIV",{class:!0});var $a=i(Ve);g(Wo.$$.fragment,$a),zl=p($a),No=r($a,"P",{});var Fa=i(No);xl=s(Fa,`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
`),Ft=r(Fa,"A",{href:!0});var Bp=i(Ft);Il=s(Bp,"batch_decode()"),Bp.forEach(t),Rl=s(Fa,". Please refer to the docstring of this method for more information."),Fa.forEach(t),$a.forEach(t),Xl=p(oe),Ye=r(oe,"DIV",{class:!0});var Wa=i(Ye);g(zo.$$.fragment,Wa),Bl=p(Wa),xo=r(Wa,"P",{});var Na=i(xo);ql=s(Na,"This method forwards all its arguments to T5Tokenizer\u2019s "),Wt=r(Na,"A",{href:!0});var qp=i(Wt);Vl=s(qp,"decode()"),qp.forEach(t),Yl=s(Na,`. Please refer to the
docstring of this method for more information.`),Na.forEach(t),Wa.forEach(t),oe.forEach(t),sa=p(e),fe=r(e,"H2",{class:!0});var za=i(fe);Ae=r(za,"A",{id:!0,class:!0,href:!0});var Vp=i(Ae);Dn=r(Vp,"SPAN",{});var Yp=i(Dn);g(Io.$$.fragment,Yp),Yp.forEach(t),Vp.forEach(t),Al=p(za),Hn=r(za,"SPAN",{});var Ap=i(Hn);Pl=s(Ap,"MusicgenModel"),Ap.forEach(t),za.forEach(t),aa=p(e),J=r(e,"DIV",{class:!0});var R=i(J);g(Ro.$$.fragment,R),Sl=p(R),Ln=r(R,"P",{});var Pp=i(Ln);Ql=s(Pp,"The bare Musicgen decoder model outputting raw hidden-states without any specific head on top."),Pp.forEach(t),Dl=p(R),Xo=r(R,"P",{});var xa=i(Xo);Hl=s(xa,"The Musicgen model was proposed in "),Bo=r(xa,"A",{href:!0,rel:!0});var Sp=i(Bo);Ll=s(Sp,"Simple and Controllable Music Generation"),Sp.forEach(t),Ol=s(xa,` 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`),xa.forEach(t),Kl=p(R),qo=r(R,"P",{});var Ia=i(qo);ed=s(Ia,"This model inherits from "),Nt=r(Ia,"A",{href:!0});var Qp=i(Nt);od=s(Qp,"PreTrainedModel"),Qp.forEach(t),td=s(Ia,`. 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.)`),Ia.forEach(t),nd=p(R),Vo=r(R,"P",{});var Ra=i(Vo);sd=s(Ra,"This model is also a PyTorch "),Yo=r(Ra,"A",{href:!0,rel:!0});var Dp=i(Yo);ad=s(Dp,"torch.nn.Module"),Dp.forEach(t),rd=s(Ra,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ra.forEach(t),id=p(R),O=r(R,"DIV",{class:!0});var Lt=i(O);g(Ao.$$.fragment,Lt),ld=p(Lt),ge=r(Lt,"P",{});var Ot=i(ge);dd=s(Ot,"The "),zt=r(Ot,"A",{href:!0});var Hp=i(zt);cd=s(Hp,"MusicgenModel"),Hp.forEach(t),pd=s(Ot," forward method, overrides the "),On=r(Ot,"CODE",{});var Lp=i(On);hd=s(Lp,"__call__"),Lp.forEach(t),ud=s(Ot," special method."),Ot.forEach(t),md=p(Lt),g(Pe.$$.fragment,Lt),Lt.forEach(t),R.forEach(t),ra=p(e),_e=r(e,"H2",{class:!0});var Xa=i(_e);Se=r(Xa,"A",{id:!0,class:!0,href:!0});var Op=i(Se);Kn=r(Op,"SPAN",{});var Kp=i(Kn);g(Po.$$.fragment,Kp),Kp.forEach(t),Op.forEach(t),fd=p(Xa),es=r(Xa,"SPAN",{});var eh=i(es);gd=s(eh,"MusicgenForCausalLM"),eh.forEach(t),Xa.forEach(t),ia=p(e),C=r(e,"DIV",{class:!0});var X=i(C);g(So.$$.fragment,X),_d=p(X),os=r(X,"P",{});var oh=i(os);bd=s(oh,"The MusicGen decoder model with a language modelling head on top."),oh.forEach(t),Md=p(X),Qo=r(X,"P",{});var Ba=i(Qo);yd=s(Ba,"The Musicgen model was proposed in "),Do=r(Ba,"A",{href:!0,rel:!0});var th=i(Do);vd=s(th,"Simple and Controllable Music Generation"),th.forEach(t),wd=s(Ba,` 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`),Ba.forEach(t),Td=p(X),Ho=r(X,"P",{});var qa=i(Ho);kd=s(qa,"This model inherits from "),xt=r(qa,"A",{href:!0});var nh=i(xt);jd=s(nh,"PreTrainedModel"),nh.forEach(t),Jd=s(qa,`. 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.)`),qa.forEach(t),Cd=p(X),Lo=r(X,"P",{});var Va=i(Lo);Gd=s(Va,"This model is also a PyTorch "),Oo=r(Va,"A",{href:!0,rel:!0});var sh=i(Oo);Zd=s(sh,"torch.nn.Module"),sh.forEach(t),Ud=s(Va,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Va.forEach(t),Ed=p(X),K=r(X,"DIV",{class:!0});var Kt=i(K);g(Ko.$$.fragment,Kt),$d=p(Kt),be=r(Kt,"P",{});var en=i(be);Fd=s(en,"The "),It=r(en,"A",{href:!0});var ah=i(It);Wd=s(ah,"MusicgenForCausalLM"),ah.forEach(t),Nd=s(en," forward method, overrides the "),ts=r(en,"CODE",{});var rh=i(ts);zd=s(rh,"__call__"),rh.forEach(t),xd=s(en," special method."),en.forEach(t),Id=p(Kt),g(Qe.$$.fragment,Kt),Kt.forEach(t),X.forEach(t),la=p(e),Me=r(e,"H2",{class:!0});var Ya=i(Me);De=r(Ya,"A",{id:!0,class:!0,href:!0});var ih=i(De);ns=r(ih,"SPAN",{});var lh=i(ns);g(et.$$.fragment,lh),lh.forEach(t),ih.forEach(t),Rd=p(Ya),ss=r(Ya,"SPAN",{});var dh=i(ss);Xd=s(dh,"MusicgenForConditionalGeneration"),dh.forEach(t),Ya.forEach(t),da=p(e),G=r(e,"DIV",{class:!0});var B=i(G);g(ot.$$.fragment,B),Bd=p(B),as=r(B,"P",{});var ch=i(as);qd=s(ch,"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."),ch.forEach(t),Vd=p(B),tt=r(B,"P",{});var Aa=i(tt);Yd=s(Aa,"The Musicgen model was proposed in "),nt=r(Aa,"A",{href:!0,rel:!0});var ph=i(nt);Ad=s(ph,"Simple and Controllable Music Generation"),ph.forEach(t),Pd=s(Aa,` 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`),Aa.forEach(t),Sd=p(B),st=r(B,"P",{});var Pa=i(st);Qd=s(Pa,"This model inherits from "),Rt=r(Pa,"A",{href:!0});var hh=i(Rt);Dd=s(hh,"PreTrainedModel"),hh.forEach(t),Hd=s(Pa,`. 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.)`),Pa.forEach(t),Ld=p(B),at=r(B,"P",{});var Sa=i(at);Od=s(Sa,"This model is also a PyTorch "),rt=r(Sa,"A",{href:!0,rel:!0});var uh=i(rt);Kd=s(uh,"torch.nn.Module"),uh.forEach(t),ec=s(Sa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Sa.forEach(t),oc=p(B),I=r(B,"DIV",{class:!0});var oo=i(I);g(it.$$.fragment,oo),tc=p(oo),ye=r(oo,"P",{});var on=i(ye);nc=s(on,"The "),Xt=r(on,"A",{href:!0});var mh=i(Xt);sc=s(mh,"MusicgenForConditionalGeneration"),mh.forEach(t),ac=s(on," forward method, overrides the "),rs=r(on,"CODE",{});var fh=i(rs);rc=s(fh,"__call__"),fh.forEach(t),ic=s(on," special method."),on.forEach(t),lc=p(oo),g(He.$$.fragment,oo),dc=p(oo),g(Le.$$.fragment,oo),oo.forEach(t),B.forEach(t),this.h()},h(){d(m,"name","hf:doc:metadata"),d(m,"content",JSON.stringify(Zh)),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(no,"href","https://arxiv.org/abs/2306.05284"),d(no,"rel","nofollow"),d(so,"href","https://huggingface.co/sanchit-gandhi"),d(so,"rel","nofollow"),d(ao,"href","https://github.com/facebookresearch/audiocraft"),d(ao,"rel","nofollow"),d(ro,"href","https://huggingface.co/models?sort=downloads&search=facebook%2Fmusicgen-"),d(ro,"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(ut,"href","/docs/transformers/v4.32.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(mt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenProcessor"),d(ft,"href","/docs/transformers/v4.32.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(bt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenForCausalLM"),d(Mt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(yt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenForCausalLM"),d(vt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(wt,"href","/docs/transformers/v4.32.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(Jo,"href","https://huggingface.co/facebook/musicgen-small"),d(Jo,"rel","nofollow"),d(kt,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(jt,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(Y,"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(Jt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenModel"),d(Ct,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(Gt,"href","/docs/transformers/v4.32.0/en/main_classes/configuration#transformers.PretrainedConfig"),d(Zt,"href","/docs/transformers/v4.32.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(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(qe,"id","transformers.MusicgenProcessor"),d(qe,"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(qe,"href","#transformers.MusicgenProcessor"),d(me,"class","relative group"),d(Ut,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenProcessor"),d(Et,"href","/docs/transformers/v4.32.0/en/model_doc/encodec#transformers.EncodecFeatureExtractor"),d($t,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenProcessor.decode"),d(Ft,"href","/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode"),d(Ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Wt,"href","/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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(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(Ae,"id","transformers.MusicgenModel"),d(Ae,"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(Ae,"href","#transformers.MusicgenModel"),d(fe,"class","relative group"),d(Bo,"href","https://arxiv.org/abs/2306.05284"),d(Bo,"rel","nofollow"),d(Nt,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),d(Yo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(Yo,"rel","nofollow"),d(zt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenModel"),d(O,"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(Se,"id","transformers.MusicgenForCausalLM"),d(Se,"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(Se,"href","#transformers.MusicgenForCausalLM"),d(_e,"class","relative group"),d(Do,"href","https://arxiv.org/abs/2306.05284"),d(Do,"rel","nofollow"),d(xt,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),d(Oo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(Oo,"rel","nofollow"),d(It,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenForCausalLM"),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.MusicgenForConditionalGeneration"),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.MusicgenForConditionalGeneration"),d(Me,"class","relative group"),d(nt,"href","https://arxiv.org/abs/2306.05284"),d(nt,"rel","nofollow"),d(Rt,"href","/docs/transformers/v4.32.0/en/main_classes/model#transformers.PreTrainedModel"),d(rt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),d(rt,"rel","nofollow"),d(Xt,"href","/docs/transformers/v4.32.0/en/model_doc/musicgen#transformers.MusicgenForConditionalGeneration"),d(I,"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")},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,Qa),h(e,ps,l),h(e,te,l),o(te,ve),o(ve,tn),_(to,tn,null),o(te,Da),o(te,nn),o(nn,Ha),h(e,hs,l),h(e,we,l),o(we,La),o(we,no),o(no,Oa),o(we,Ka),h(e,us,l),h(e,Te,l),o(Te,er),o(Te,sn),o(sn,or),o(Te,tr),h(e,ms,l),h(e,ct,l),o(ct,nr),h(e,fs,l),h(e,pt,l),o(pt,sr),h(e,gs,l),h(e,ht,l),o(ht,an),o(an,ar),h(e,_s,l),h(e,N,l),o(N,rr),o(N,so),o(so,ir),o(N,lr),o(N,ao),o(ao,dr),o(N,cr),o(N,ro),o(ro,pr),o(N,hr),h(e,bs,l),h(e,ne,l),o(ne,ke),o(ke,rn),_(io,rn,null),o(ne,ur),o(ne,ln),o(ln,mr),h(e,Ms,l),h(e,P,l),o(P,fr),o(P,dn),o(dn,gr),o(P,_r),o(P,cn),o(cn,br),o(P,Mr),h(e,ys,l),h(e,se,l),o(se,je),o(je,pn),_(lo,pn,null),o(se,yr),o(se,hn),o(hn,vr),h(e,vs,l),h(e,Je,l),o(Je,wr),o(Je,un),o(un,Tr),o(Je,kr),h(e,ws,l),_(co,e,l),h(e,Ts,l),h(e,Ce,l),o(Ce,jr),o(Ce,mn),o(mn,Jr),o(Ce,Cr),h(e,ks,l),_(po,e,l),h(e,js,l),h(e,S,l),o(S,Gr),o(S,fn),o(fn,Zr),o(S,Ur),o(S,gn),o(gn,Er),o(S,$r),h(e,Js,l),_(ho,e,l),h(e,Cs,l),h(e,ae,l),o(ae,Ge),o(Ge,_n),_(uo,_n,null),o(ae,Fr),o(ae,bn),o(bn,Wr),h(e,Gs,l),h(e,Ze,l),o(Ze,Nr),o(Ze,ut),o(ut,zr),o(Ze,xr),h(e,Zs,l),_(mo,e,l),h(e,Us,l),h(e,z,l),o(z,Ir),o(z,Mn),o(Mn,Rr),o(z,Xr),o(z,yn),o(yn,Br),o(z,qr),o(z,vn),o(vn,Vr),o(z,Yr),h(e,Es,l),h(e,re,l),o(re,Ue),o(Ue,wn),_(fo,wn,null),o(re,Ar),o(re,Tn),o(Tn,Pr),h(e,$s,l),h(e,Ee,l),o(Ee,Sr),o(Ee,mt),o(mt,Qr),o(Ee,Dr),h(e,Fs,l),_(go,e,l),h(e,Ws,l),_(_o,e,l),h(e,Ns,l),h(e,Q,l),o(Q,Hr),o(Q,kn),o(kn,Lr),o(Q,Or),o(Q,ft),o(ft,Kr),o(Q,ei),h(e,zs,l),_(bo,e,l),h(e,xs,l),h(e,ie,l),o(ie,$e),o($e,jn),_(Mo,jn,null),o(ie,oi),o(ie,Jn),o(Jn,ti),h(e,Is,l),h(e,gt,l),o(gt,ni),h(e,Rs,l),_(yo,e,l),h(e,Xs,l),h(e,x,l),o(x,si),o(x,Cn),o(Cn,ai),o(x,ri),o(x,Gn),o(Gn,ii),o(x,li),o(x,Zn),o(Zn,di),o(x,ci),h(e,Bs,l),h(e,le,l),o(le,Fe),o(Fe,Un),_(vo,Un,null),o(le,pi),o(le,En),o(En,hi),h(e,qs,l),h(e,_t,l),o(_t,ui),h(e,Vs,l),h(e,D,l),o(D,$n),o($n,mi),o(D,fi),o(D,Fn),o(Fn,gi),o(D,_i),o(D,Wn),o(Wn,bi),h(e,Ys,l),h(e,H,l),o(H,Mi),o(H,bt),o(bt,yi),o(H,vi),o(H,Mt),o(Mt,wi),o(H,Ti),h(e,As,l),h(e,L,l),o(L,ki),o(L,yt),o(yt,ji),o(L,Ji),o(L,vt),o(vt,Ci),o(L,Gi),h(e,Ps,l),h(e,We,l),o(We,Zi),o(We,wt),o(wt,Ui),o(We,Ei),h(e,Ss,l),_(wo,e,l),h(e,Qs,l),h(e,Ne,l),o(Ne,$i),o(Ne,Nn),o(Nn,Fi),o(Ne,Wi),h(e,Ds,l),_(To,e,l),h(e,Hs,l),h(e,Tt,l),o(Tt,Ni),h(e,Ls,l),h(e,ze,l),o(ze,zn),o(zn,zi),o(ze,xi),o(ze,xe),o(xe,Ii),o(xe,xn),o(xn,Ri),o(xe,Xi),o(xe,In),o(In,Bi),h(e,Os,l),h(e,de,l),o(de,Ie),o(Ie,Rn),_(ko,Rn,null),o(de,qi),o(de,Xn),o(Xn,Vi),h(e,Ks,l),h(e,Y,l),_(jo,Y,null),o(Y,Yi),o(Y,ce),o(ce,Ai),o(ce,Bn),o(Bn,Pi),o(ce,Si),o(ce,Jo),o(Jo,Qi),o(ce,Di),o(Y,Hi),o(Y,pe),o(pe,Li),o(pe,kt),o(kt,Oi),o(pe,Ki),o(pe,jt),o(jt,el),o(pe,ol),h(e,ea,l),h(e,he,l),o(he,Re),o(Re,qn),_(Co,qn,null),o(he,tl),o(he,Vn),o(Vn,nl),h(e,oa,l),h(e,Z,l),_(Go,Z,null),o(Z,sl),o(Z,Zo),o(Zo,al),o(Zo,Jt),o(Jt,rl),o(Zo,il),o(Z,ll),o(Z,ue),o(ue,dl),o(ue,Ct),o(Ct,cl),o(ue,pl),o(ue,Gt),o(Gt,hl),o(ue,ul),o(Z,ml),_(Xe,Z,null),o(Z,fl),o(Z,Be),_(Uo,Be,null),o(Be,gl),o(Be,Eo),o(Eo,_l),o(Eo,Zt),o(Zt,bl),o(Eo,Ml),h(e,ta,l),h(e,me,l),o(me,qe),o(qe,Yn),_($o,Yn,null),o(me,yl),o(me,An),o(An,vl),h(e,na,l),h(e,U,l),_(Fo,U,null),o(U,wl),o(U,Pn),o(Pn,Tl),o(U,kl),o(U,$),o($,Ut),o(Ut,jl),o($,Jl),o($,Et),o(Et,Cl),o($,Gl),o($,Sn),o(Sn,Zl),o($,Ul),o($,Qn),o(Qn,El),o($,$l),o($,$t),o($t,Fl),o($,Wl),o(U,Nl),o(U,Ve),_(Wo,Ve,null),o(Ve,zl),o(Ve,No),o(No,xl),o(No,Ft),o(Ft,Il),o(No,Rl),o(U,Xl),o(U,Ye),_(zo,Ye,null),o(Ye,Bl),o(Ye,xo),o(xo,ql),o(xo,Wt),o(Wt,Vl),o(xo,Yl),h(e,sa,l),h(e,fe,l),o(fe,Ae),o(Ae,Dn),_(Io,Dn,null),o(fe,Al),o(fe,Hn),o(Hn,Pl),h(e,aa,l),h(e,J,l),_(Ro,J,null),o(J,Sl),o(J,Ln),o(Ln,Ql),o(J,Dl),o(J,Xo),o(Xo,Hl),o(Xo,Bo),o(Bo,Ll),o(Xo,Ol),o(J,Kl),o(J,qo),o(qo,ed),o(qo,Nt),o(Nt,od),o(qo,td),o(J,nd),o(J,Vo),o(Vo,sd),o(Vo,Yo),o(Yo,ad),o(Vo,rd),o(J,id),o(J,O),_(Ao,O,null),o(O,ld),o(O,ge),o(ge,dd),o(ge,zt),o(zt,cd),o(ge,pd),o(ge,On),o(On,hd),o(ge,ud),o(O,md),_(Pe,O,null),h(e,ra,l),h(e,_e,l),o(_e,Se),o(Se,Kn),_(Po,Kn,null),o(_e,fd),o(_e,es),o(es,gd),h(e,ia,l),h(e,C,l),_(So,C,null),o(C,_d),o(C,os),o(os,bd),o(C,Md),o(C,Qo),o(Qo,yd),o(Qo,Do),o(Do,vd),o(Qo,wd),o(C,Td),o(C,Ho),o(Ho,kd),o(Ho,xt),o(xt,jd),o(Ho,Jd),o(C,Cd),o(C,Lo),o(Lo,Gd),o(Lo,Oo),o(Oo,Zd),o(Lo,Ud),o(C,Ed),o(C,K),_(Ko,K,null),o(K,$d),o(K,be),o(be,Fd),o(be,It),o(It,Wd),o(be,Nd),o(be,ts),o(ts,zd),o(be,xd),o(K,Id),_(Qe,K,null),h(e,la,l),h(e,Me,l),o(Me,De),o(De,ns),_(et,ns,null),o(Me,Rd),o(Me,ss),o(ss,Xd),h(e,da,l),h(e,G,l),_(ot,G,null),o(G,Bd),o(G,as),o(as,qd),o(G,Vd),o(G,tt),o(tt,Yd),o(tt,nt),o(nt,Ad),o(tt,Pd),o(G,Sd),o(G,st),o(st,Qd),o(st,Rt),o(Rt,Dd),o(st,Hd),o(G,Ld),o(G,at),o(at,Od),o(at,rt),o(rt,Kd),o(at,ec),o(G,oc),o(G,I),_(it,I,null),o(I,tc),o(I,ye),o(ye,nc),o(ye,Xt),o(Xt,sc),o(ye,ac),o(ye,rs),o(rs,rc),o(ye,ic),o(I,lc),_(He,I,null),o(I,dc),_(Le,I,null),ca=!0},p(e,[l]){const lt={};l&2&&(lt.$$scope={dirty:l,ctx:e}),Xe.$set(lt);const is={};l&2&&(is.$$scope={dirty:l,ctx:e}),Pe.$set(is);const ls={};l&2&&(ls.$$scope={dirty:l,ctx:e}),Qe.$set(ls);const ds={};l&2&&(ds.$$scope={dirty:l,ctx:e}),He.$set(ds);const dt={};l&2&&(dt.$$scope={dirty:l,ctx:e}),Le.$set(dt)},i(e){ca||(b(u.$$.fragment,e),b(to.$$.fragment,e),b(io.$$.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(Co.$$.fragment,e),b(Go.$$.fragment,e),b(Xe.$$.fragment,e),b(Uo.$$.fragment,e),b($o.$$.fragment,e),b(Fo.$$.fragment,e),b(Wo.$$.fragment,e),b(zo.$$.fragment,e),b(Io.$$.fragment,e),b(Ro.$$.fragment,e),b(Ao.$$.fragment,e),b(Pe.$$.fragment,e),b(Po.$$.fragment,e),b(So.$$.fragment,e),b(Ko.$$.fragment,e),b(Qe.$$.fragment,e),b(et.$$.fragment,e),b(ot.$$.fragment,e),b(it.$$.fragment,e),b(He.$$.fragment,e),b(Le.$$.fragment,e),ca=!0)},o(e){M(u.$$.fragment,e),M(to.$$.fragment,e),M(io.$$.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(Co.$$.fragment,e),M(Go.$$.fragment,e),M(Xe.$$.fragment,e),M(Uo.$$.fragment,e),M($o.$$.fragment,e),M(Fo.$$.fragment,e),M(Wo.$$.fragment,e),M(zo.$$.fragment,e),M(Io.$$.fragment,e),M(Ro.$$.fragment,e),M(Ao.$$.fragment,e),M(Pe.$$.fragment,e),M(Po.$$.fragment,e),M(So.$$.fragment,e),M(Ko.$$.fragment,e),M(Qe.$$.fragment,e),M(et.$$.fragment,e),M(ot.$$.fragment,e),M(it.$$.fragment,e),M(He.$$.fragment,e),M(Le.$$.fragment,e),ca=!1},d(e){t(m),e&&t(j),e&&t(w),y(u),e&&t(ps),e&&t(te),y(to),e&&t(hs),e&&t(we),e&&t(us),e&&t(Te),e&&t(ms),e&&t(ct),e&&t(fs),e&&t(pt),e&&t(gs),e&&t(ht),e&&t(_s),e&&t(N),e&&t(bs),e&&t(ne),y(io),e&&t(Ms),e&&t(P),e&&t(ys),e&&t(se),y(lo),e&&t(vs),e&&t(Je),e&&t(ws),y(co,e),e&&t(Ts),e&&t(Ce),e&&t(ks),y(po,e),e&&t(js),e&&t(S),e&&t(Js),y(ho,e),e&&t(Cs),e&&t(ae),y(uo),e&&t(Gs),e&&t(Ze),e&&t(Zs),y(mo,e),e&&t(Us),e&&t(z),e&&t(Es),e&&t(re),y(fo),e&&t($s),e&&t(Ee),e&&t(Fs),y(go,e),e&&t(Ws),y(_o,e),e&&t(Ns),e&&t(Q),e&&t(zs),y(bo,e),e&&t(xs),e&&t(ie),y(Mo),e&&t(Is),e&&t(gt),e&&t(Rs),y(yo,e),e&&t(Xs),e&&t(x),e&&t(Bs),e&&t(le),y(vo),e&&t(qs),e&&t(_t),e&&t(Vs),e&&t(D),e&&t(Ys),e&&t(H),e&&t(As),e&&t(L),e&&t(Ps),e&&t(We),e&&t(Ss),y(wo,e),e&&t(Qs),e&&t(Ne),e&&t(Ds),y(To,e),e&&t(Hs),e&&t(Tt),e&&t(Ls),e&&t(ze),e&&t(Os),e&&t(de),y(ko),e&&t(Ks),e&&t(Y),y(jo),e&&t(ea),e&&t(he),y(Co),e&&t(oa),e&&t(Z),y(Go),y(Xe),y(Uo),e&&t(ta),e&&t(me),y($o),e&&t(na),e&&t(U),y(Fo),y(Wo),y(zo),e&&t(sa),e&&t(fe),y(Io),e&&t(aa),e&&t(J),y(Ro),y(Ao),y(Pe),e&&t(ra),e&&t(_e),y(Po),e&&t(ia),e&&t(C),y(So),y(Ko),y(Qe),e&&t(la),e&&t(Me),y(et),e&&t(da),e&&t(G),y(ot),y(it),y(He),y(Le)}}}const Zh={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 Uh(W){return wh(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xh extends bh{constructor(m){super();Mh(this,m,Uh,Gh,yh,{})}}export{xh as default,Zh as metadata};
