import{S as gc,i as _c,s as vc,e as n,k as d,w as x,t as a,M as bc,c as r,d as o,m as p,a as s,x as y,h as i,b as c,G as e,g,y as T,q as w,o as P,B as M,v as xc,L as Ht}from"../../chunks/vendor-hf-doc-builder.js";import{T as Bi}from"../../chunks/Tip-hf-doc-builder.js";import{D as z}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Yt}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as A}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as At}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function yc(k){let u,b,_,m,v;return m=new Yt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFBpeDJTdHJ1Y3RDb25maWclMkMlMjBQaXgyU3RydWN0Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFBpeDJTdHJ1Y3RDb25maWclMjB3aXRoJTIwZ29vZ2xlJTJGcGl4MnN0cnVjdC1iYXNlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFBpeDJTdHJ1Y3RDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBQaXgyU3RydWN0Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBnb29nbGUlMkZwaXgyc3RydWN0LWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFBpeDJTdHJ1Y3RGb3JDb25kaXRpb25hbEdlbmVyYXRpb24oY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmlnJTBBJTBBJTIzJTIwV2UlMjBjYW4lMjBhbHNvJTIwaW5pdGlhbGl6ZSUyMGElMjBQaXgyU3RydWN0Q29uZmlnJTIwZnJvbSUyMGElMjBQaXgyU3RydWN0VGV4dENvbmZpZyUyMGFuZCUyMGElMjBQaXgyU3RydWN0VmlzaW9uQ29uZmlnJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFBpeDJTdHJ1Y3QlMjB0ZXh0JTIwYW5kJTIwUGl4MlN0cnVjdCUyMHZpc2lvbiUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWdfdGV4dCUyMCUzRCUyMFBpeDJTdHJ1Y3RUZXh0Q29uZmlnKCklMEFjb25maWdfdmlzaW9uJTIwJTNEJTIwUGl4MlN0cnVjdFZpc2lvbkNvbmZpZygpJTBBJTBBY29uZmlnJTIwJTNEJTIwUGl4MlN0cnVjdENvbmZpZy5mcm9tX3RleHRfdmlzaW9uX2NvbmZpZ3MoY29uZmlnX3RleHQlMkMlMjBjb25maWdfdmlzaW9uKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Pix2StructConfig, Pix2StructForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2StructConfig with google/pix2struct-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Pix2StructConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2StructForConditionalGeneration (with random weights) from the google/pix2struct-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructForConditionalGeneration(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><span class="hljs-comment"># We can also initialize a Pix2StructConfig from a Pix2StructTextConfig and a Pix2StructVisionConfig</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2Struct text and Pix2Struct vision configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_text = Pix2StructTextConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>config_vision = Pix2StructVisionConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = Pix2StructConfig.from_text_vision_configs(config_text, config_vision)`}}),{c(){u=n("p"),b=a("Example:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Example:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function Tc(k){let u,b,_,m,v;return m=new Yt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFBpeDJTdHJ1Y3RUZXh0Q29uZmlnJTJDJTIwUGl4MlN0cnVjdFRleHRNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBQaXgyU3RydWN0VGV4dENvbmZpZyUyMHdpdGglMjBnb29nbGUlMkZwaXgyc3RydWN0LWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwUGl4MlN0cnVjdFRleHRDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBQaXgyU3RydWN0VGV4dE1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBnb29nbGUlMkZwaXgyc3RydWN0LWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFBpeDJTdHJ1Y3RUZXh0TW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Pix2StructTextConfig, Pix2StructTextModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2StructTextConfig with google/pix2struct-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Pix2StructTextConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2StructTextModel (with random weights) from the google/pix2struct-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructTextModel(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`}}),{c(){u=n("p"),b=a("Example:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Example:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function wc(k){let u,b,_,m,v;return m=new Yt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFBpeDJTdHJ1Y3RWaXNpb25Db25maWclMkMlMjBQaXgyU3RydWN0VmlzaW9uTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwUGl4MlN0cnVjdFZpc2lvbkNvbmZpZyUyMHdpdGglMjBnb29nbGUlMkZwaXgyc3RydWN0LWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwUGl4MlN0cnVjdFZpc2lvbkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFBpeDJTdHJ1Y3RWaXNpb25Nb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwZ29vZ2xlJTJGcGl4MnN0cnVjdC1iYXNlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBQaXgyU3RydWN0VmlzaW9uTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Pix2StructVisionConfig, Pix2StructVisionModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2StructVisionConfig with google/pix2struct-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Pix2StructVisionConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Pix2StructVisionModel (with random weights) from the google/pix2struct-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructVisionModel(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`}}),{c(){u=n("p"),b=a("Example:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Example:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function Pc(k){let u,b,_,m,v;return{c(){u=n("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),m=a("Module"),v=a(`
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(l){u=r(l,"P",{});var f=s(u);b=i(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(f,"CODE",{});var E=s(_);m=i(E,"Module"),E.forEach(o),v=i(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(l,f){g(l,u,f),e(u,b),e(u,_),e(_,m),e(u,v)},d(l){l&&o(u)}}}function Mc(k){let u,b,_,m,v;return m=new Yt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBQaXgyU3RydWN0VGV4dE1vZGVsJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcGl4MnN0cnVjdC10ZXh0Y2Fwcy1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwUGl4MlN0cnVjdFRleHRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcGl4MnN0cnVjdC10ZXh0Y2Fwcy1iYXNlJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3Nvcih0ZXh0JTNEJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3M=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Pix2StructTextModel

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-textcaps-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructTextModel.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-textcaps-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){u=n("p"),b=a("Example:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Example:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function kc(k){let u,b,_,m,v;return{c(){u=n("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),m=a("Module"),v=a(`
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(l){u=r(l,"P",{});var f=s(u);b=i(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(f,"CODE",{});var E=s(_);m=i(E,"Module"),E.forEach(o),v=i(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(l,f){g(l,u,f),e(u,b),e(u,_),e(_,m),e(u,v)},d(l){l&&o(u)}}}function Sc(k){let u,b,_,m,v;return m=new Yt({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMFBpeDJTdHJ1Y3RWaXNpb25Nb2RlbCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnBpeDJzdHJ1Y3QtdGV4dGNhcHMtYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMFBpeDJTdHJ1Y3RWaXNpb25Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGcGl4MnN0cnVjdC10ZXh0Y2Fwcy1iYXNlJTIyKSUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGd3d3LmlsYW5rZWxtYW4ub3JnJTJGc3RvcHNpZ25zJTJGYXVzdHJhbGlhLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRlJTBBbGlzdChsYXN0X2hpZGRlbl9zdGF0ZXMuc2hhcGUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Pix2StructVisionModel

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-textcaps-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructVisionModel.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-textcaps-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://www.ilankelman.org/stopsigns/australia.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">2048</span>, <span class="hljs-number">768</span>]`}}),{c(){u=n("p"),b=a("Example:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Example:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function $c(k){let u,b,_,m,v;return{c(){u=n("p"),b=a("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=n("code"),m=a("Module"),v=a(`
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(l){u=r(l,"P",{});var f=s(u);b=i(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r(f,"CODE",{});var E=s(_);m=i(E,"Module"),E.forEach(o),v=i(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(o)},m(l,f){g(l,u,f),e(u,b),e(u,_),e(_,m),e(u,v)},d(l){l&&o(u)}}}function Jc(k){let u,b,_,m,v;return m=new Yt({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMFBpeDJTdHJ1Y3RGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZwaXgyc3RydWN0LXRleHRjYXBzLWJhc2UlMjIpJTBBbW9kZWwlMjAlM0QlMjBQaXgyU3RydWN0Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZwaXgyc3RydWN0LXRleHRjYXBzLWJhc2UlMjIpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZ3d3cuaWxhbmtlbG1hbi5vcmclMkZzdG9wc2lnbnMlMkZhdXN0cmFsaWEuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjBhdXRvcmVncmVzc2l2ZSUyMGdlbmVyYXRpb24lMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDUwKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQXByaW50KGdlbmVyYXRlZF90ZXh0KSUwQSUwQSUyMyUyMGNvbmRpdGlvbmFsJTIwZ2VuZXJhdGlvbiUwQXRleHQlMjAlM0QlMjAlMjJBJTIwcGljdHVyZSUyMG9mJTIyJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0ZXh0JTJDJTIwaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNERmFsc2UpJTBBJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0Q1MCklMEFnZW5lcmF0ZWRfdGV4dCUyMCUzRCUyMHByb2Nlc3Nvci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQlMEFwcmludChnZW5lcmF0ZWRfdGV4dCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Pix2StructForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-textcaps-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-textcaps-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://www.ilankelman.org/stopsigns/australia.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># autoregressive generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">50</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_text)
A stop sign <span class="hljs-keyword">is</span> on a street corner.

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># conditional generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;A picture of&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=text, images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, add_special_tokens=<span class="hljs-literal">False</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">50</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_text)
A picture of a stop sign <span class="hljs-keyword">with</span> a red stop sign`}}),{c(){u=n("p"),b=a("Inference:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Inference:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function Cc(k){let u,b,_,m,v;return m=new Yt({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Byb2Nlc3NvciUyQyUyMFBpeDJTdHJ1Y3RGb3JDb25kaXRpb25hbEdlbmVyYXRpb24lMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZwaXgyc3RydWN0LWJhc2UlMjIpJTBBbW9kZWwlMjAlM0QlMjBQaXgyU3RydWN0Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZwaXgyc3RydWN0LWJhc2UlMjIpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZ3d3cuaWxhbmtlbG1hbi5vcmclMkZzdG9wc2lnbnMlMkZhdXN0cmFsaWEuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBdGV4dCUyMCUzRCUyMCUyMkElMjBzdG9wJTIwc2lnbiUyMGlzJTIwb24lMjB0aGUlMjBzdHJlZXQlMjBjb3JuZXIuJTIyJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFsYWJlbHMlMjAlM0QlMjBwcm9jZXNzb3IodGV4dCUzRHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHMlMEElMEElMjMlMjBmb3J3YXJkJTIwcGFzcyUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscyklMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBcHJpbnQoZiUyMiU3Qmxvc3MuaXRlbSgpJTNBLjVmJTdEJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Pix2StructForConditionalGeneration

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Pix2StructForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;google/pix2struct-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://www.ilankelman.org/stopsigns/australia.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;A stop sign is on the street corner.&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = processor(text=text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;<span class="hljs-subst">{loss.item():<span class="hljs-number">.5</span>f}</span>&quot;</span>)
<span class="hljs-number">5.94282</span>`}}),{c(){u=n("p"),b=a("Training:"),_=d(),x(m.$$.fragment)},l(l){u=r(l,"P",{});var f=s(u);b=i(f,"Training:"),f.forEach(o),_=p(l),y(m.$$.fragment,l)},m(l,f){g(l,u,f),e(u,b),g(l,_,f),T(m,l,f),v=!0},p:Ht,i(l){v||(w(m.$$.fragment,l),v=!0)},o(l){P(m.$$.fragment,l),v=!1},d(l){l&&o(u),l&&o(_),M(m,l)}}}function jc(k){let u,b,_,m,v,l,f,E,yr,wn,O,ge,Eo,He,Tr,Uo,wr,Pn,_e,Pr,Ye,Mr,kr,Mn,Dt,Sr,kn,Qt,Io,$r,Sn,Lt,Jr,$n,Ot,Cr,Jn,ve,jr,Wo,zr,Er,Cn,H,Ur,De,Ir,Wr,Qe,Fr,Nr,jn,K,be,Fo,Le,Vr,No,Zr,zn,xe,Vo,Oe,Br,Rr,Zo,Ke,Gr,En,ee,ye,Bo,et,qr,Ro,Xr,Un,C,tt,Ar,Y,Kt,Hr,Yr,eo,Dr,Qr,ot,Lr,Or,Kr,te,es,to,ts,os,oo,ns,rs,ss,Te,as,we,nt,is,rt,ls,no,cs,ds,In,oe,Pe,Go,st,ps,qo,us,Wn,I,at,hs,ne,ms,ro,fs,gs,it,_s,vs,bs,re,xs,so,ys,Ts,ao,ws,Ps,Ms,Me,Fn,se,ke,Xo,lt,ks,Ao,Ss,Nn,W,ct,$s,ae,Js,io,Cs,js,dt,zs,Es,Us,ie,Is,lo,Ws,Fs,co,Ns,Vs,Zs,Se,Vn,le,$e,Ho,pt,Bs,Yo,Rs,Zn,j,ut,Gs,Do,qs,Xs,U,po,As,Hs,uo,Ys,Ds,ho,Qs,Ls,Qo,Os,Ks,mo,ea,ta,oa,Je,ht,na,mt,ra,fo,sa,aa,ia,Ce,ft,la,gt,ca,go,da,pa,Bn,ce,je,Lo,_t,ua,Oo,ha,Rn,G,vt,ma,Ko,fa,ga,ze,bt,_a,F,va,en,ba,xa,tn,ya,Ta,on,wa,Pa,xt,Ma,ka,Gn,de,Ee,nn,yt,Sa,rn,$a,qn,S,Tt,Ja,sn,Ca,ja,wt,za,Pt,Ea,Ua,Ia,Mt,Wa,_o,Fa,Na,Va,kt,Za,St,Ba,Ra,Ga,N,$t,qa,pe,Xa,vo,Aa,Ha,an,Ya,Da,Qa,Ue,La,Ie,Xn,ue,We,ln,Jt,Oa,cn,Ka,An,q,Ct,ei,jt,ti,zt,oi,ni,ri,V,Et,si,he,ai,bo,ii,li,dn,ci,di,pi,Fe,ui,Ne,Hn,me,Ve,pn,Ut,hi,un,mi,Yn,$,It,fi,hn,gi,_i,Wt,vi,Ft,bi,xi,yi,Nt,Ti,xo,wi,Pi,Mi,Vt,ki,Zt,Si,$i,Ji,J,Bt,Ci,fe,ji,yo,zi,Ei,mn,Ui,Ii,Wi,Ze,Fi,fn,Ni,Vi,Be,Zi,Re,Dn;return l=new A({}),He=new A({}),Le=new A({}),et=new A({}),tt=new z({props:{name:"class transformers.Pix2StructConfig",anchor:"transformers.Pix2StructConfig",parameters:[{name:"text_config",val:" = None"},{name:"vision_config",val:" = None"},{name:"initializer_factor",val:" = 1.0"},{name:"initializer_range",val:" = 0.02"},{name:"is_vqa",val:" = False"},{name:"tie_word_embeddings",val:" = False"},{name:"is_encoder_decoder",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructConfig.text_config",description:`<strong>text_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructTextConfig">Pix2StructTextConfig</a>.`,name:"text_config"},{anchor:"transformers.Pix2StructConfig.vision_config",description:`<strong>vision_config</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary of configuration options used to initialize <a href="/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructVisionConfig">Pix2StructVisionConfig</a>.`,name:"vision_config"},{anchor:"transformers.Pix2StructConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Factor to multiply the initialization range with.`,name:"initializer_factor"},{anchor:"transformers.Pix2StructConfig.initializer_range",description:`<strong>initializer_range</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_range"},{anchor:"transformers.Pix2StructConfig.is_vqa",description:`<strong>is_vqa</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the model has been fine-tuned for VQA or not.`,name:"is_vqa"},{anchor:"transformers.Pix2StructConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/configuration_pix2struct.py#L304"}}),Te=new At({props:{anchor:"transformers.Pix2StructConfig.example",$$slots:{default:[yc]},$$scope:{ctx:k}}}),nt=new z({props:{name:"from_text_vision_configs",anchor:"transformers.Pix2StructConfig.from_text_vision_configs",parameters:[{name:"text_config",val:": Pix2StructTextConfig"},{name:"vision_config",val:": Pix2StructVisionConfig"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/configuration_pix2struct.py#L391",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig"
>Pix2StructConfig</a></p>
`}}),st=new A({}),at=new z({props:{name:"class transformers.Pix2StructTextConfig",anchor:"transformers.Pix2StructTextConfig",parameters:[{name:"vocab_size",val:" = 50244"},{name:"hidden_size",val:" = 768"},{name:"d_kv",val:" = 64"},{name:"d_ff",val:" = 2048"},{name:"num_layers",val:" = 12"},{name:"num_heads",val:" = 12"},{name:"relative_attention_num_buckets",val:" = 32"},{name:"relative_attention_max_distance",val:" = 128"},{name:"dropout_rate",val:" = 0.1"},{name:"layer_norm_epsilon",val:" = 1e-06"},{name:"initializer_factor",val:" = 1.0"},{name:"dense_act_fn",val:" = 'gelu_new'"},{name:"decoder_start_token_id",val:" = 0"},{name:"use_cache",val:" = False"},{name:"pad_token_id",val:" = 0"},{name:"eos_token_id",val:" = 1"},{name:"tie_word_embeddings",val:" = False"},{name:"is_decoder",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructTextConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50244) &#x2014;
Vocabulary size of the <code>Pix2Struct</code> text model. Defines the number of different tokens that can be
represented by the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructTextModel">Pix2StructTextModel</a>.`,name:"vocab_size"},{anchor:"transformers.Pix2StructTextConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.Pix2StructTextConfig.d_kv",description:`<strong>d_kv</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Dimensionality of the key, query, value projections in each attention head.`,name:"d_kv"},{anchor:"transformers.Pix2StructTextConfig.d_ff",description:`<strong>d_ff</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"d_ff"},{anchor:"transformers.Pix2StructTextConfig.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_layers"},{anchor:"transformers.Pix2StructTextConfig.num_heads",description:`<strong>num_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.Pix2StructTextConfig.relative_attention_num_buckets",description:`<strong>relative_attention_num_buckets</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of buckets to use for each attention layer.`,name:"relative_attention_num_buckets"},{anchor:"transformers.Pix2StructTextConfig.relative_attention_max_distance",description:`<strong>relative_attention_max_distance</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The maximum distance of the longer sequences for the bucket separation.`,name:"relative_attention_max_distance"},{anchor:"transformers.Pix2StructTextConfig.dropout_rate",description:`<strong>dropout_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"dropout_rate"},{anchor:"transformers.Pix2StructTextConfig.layer_norm_epsilon",description:`<strong>layer_norm_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_epsilon"},{anchor:"transformers.Pix2StructTextConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
testing).`,name:"initializer_factor"},{anchor:"transformers.Pix2StructTextConfig.dense_act_fn",description:`<strong>dense_act_fn</strong> (<code>Union[Callable, str]</code>, <em>optional</em>, defaults to <code>&quot;gelu_new&quot;</code>) &#x2014;
The non-linear activation function (function or string).`,name:"dense_act_fn"},{anchor:"transformers.Pix2StructTextConfig.decoder_start_token_id",description:`<strong>decoder_start_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The id of the <code>decoder_start_token_id</code> token.`,name:"decoder_start_token_id"},{anchor:"transformers.Pix2StructTextConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.Pix2StructTextConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The id of the <code>padding</code> token.`,name:"pad_token_id"},{anchor:"transformers.Pix2StructTextConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The id of the <code>end-of-sequence</code> token.`,name:"eos_token_id"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/configuration_pix2struct.py#L34"}}),Me=new At({props:{anchor:"transformers.Pix2StructTextConfig.example",$$slots:{default:[Tc]},$$scope:{ctx:k}}}),lt=new A({}),ct=new z({props:{name:"class transformers.Pix2StructVisionConfig",anchor:"transformers.Pix2StructVisionConfig",parameters:[{name:"hidden_size",val:" = 768"},{name:"patch_embed_hidden_size",val:" = 768"},{name:"d_ff",val:" = 2048"},{name:"d_kv",val:" = 64"},{name:"projection_dim",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"num_channels",val:" = 3"},{name:"patch_size",val:" = 16"},{name:"dense_act_fn",val:" = 'gelu_new'"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"dropout_rate",val:" = 0.0"},{name:"attention_dropout",val:" = 0.0"},{name:"initializer_range",val:" = 1e-10"},{name:"initializer_factor",val:" = 1.0"},{name:"seq_len",val:" = 4096"},{name:"layer_norm_bias",val:" = False"},{name:"relative_attention_num_buckets",val:" = 32"},{name:"relative_attention_max_distance",val:" = 128"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructVisionConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.Pix2StructVisionConfig.patch_embed_hidden_size",description:`<strong>patch_embed_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the input patch_embedding layer in the Transformer encoder.`,name:"patch_embed_hidden_size"},{anchor:"transformers.Pix2StructVisionConfig.d_ff",description:`<strong>d_ff</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"d_ff"},{anchor:"transformers.Pix2StructVisionConfig.d_kv",description:`<strong>d_kv</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Dimensionality of the key, query, value projections per attention head.`,name:"d_kv"},{anchor:"transformers.Pix2StructVisionConfig.projection_dim",description:`<strong>projection_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the projection layer in the Transformer encoder.`,name:"projection_dim"},{anchor:"transformers.Pix2StructVisionConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.Pix2StructVisionConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.Pix2StructVisionConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
Number of channels of the input images.`,name:"num_channels"},{anchor:"transformers.Pix2StructVisionConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.Pix2StructVisionConfig.dense_act_fn",description:`<strong>dense_act_fn</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu_new&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> \`<code>&quot;gelu&quot;</code> are supported.`,name:"dense_act_fn"},{anchor:"transformers.Pix2StructVisionConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.Pix2StructVisionConfig.dropout_rate",description:`<strong>dropout_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"dropout_rate"},{anchor:"transformers.Pix2StructVisionConfig.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.Pix2StructVisionConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-10) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.Pix2StructVisionConfig.initializer_factor",description:`<strong>initializer_factor</strong> (\`float&#x201C;, <em>optional</em>, defaults to 1) &#x2014;
A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
testing).`,name:"initializer_factor"},{anchor:"transformers.Pix2StructVisionConfig.seq_len",description:`<strong>seq_len</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Maximum sequence length (here number of patches) supported by the model.`,name:"seq_len"},{anchor:"transformers.Pix2StructVisionConfig.layer_norm_bias",description:`<strong>layer_norm_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add a bias to the layer normalization layers.`,name:"layer_norm_bias"},{anchor:"transformers.Pix2StructVisionConfig.relative_attention_num_buckets",description:`<strong>relative_attention_num_buckets</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of buckets to use for each attention layer.`,name:"relative_attention_num_buckets"},{anchor:"transformers.Pix2StructVisionConfig.relative_attention_max_distance",description:`<strong>relative_attention_max_distance</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The maximum distance (in tokens) to use for each attention layer.`,name:"relative_attention_max_distance"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/configuration_pix2struct.py#L171"}}),Se=new At({props:{anchor:"transformers.Pix2StructVisionConfig.example",$$slots:{default:[wc]},$$scope:{ctx:k}}}),pt=new A({}),ut=new z({props:{name:"class transformers.Pix2StructProcessor",anchor:"transformers.Pix2StructProcessor",parameters:[{name:"image_processor",val:""},{name:"tokenizer",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructProcessor.image_processor",description:`<strong>image_processor</strong> (<code>Pix2StructImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructImageProcessor">Pix2StructImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.Pix2StructProcessor.tokenizer",description:"<strong>tokenizer</strong> (Union[<code>T5TokenizerFast</code>, <code>T5Tokenizer</code>]) &#x2014;\nAn instance of [&#x2018;T5TokenizerFast`] or [&#x2018;T5Tokenizer`]. The tokenizer is a required input.",name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/processing_pix2struct.py#L26"}}),ht=new z({props:{name:"batch_decode",anchor:"transformers.Pix2StructProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/processing_pix2struct.py#L144"}}),ft=new z({props:{name:"decode",anchor:"transformers.Pix2StructProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/processing_pix2struct.py#L151"}}),_t=new A({}),vt=new z({props:{name:"class transformers.Pix2StructImageProcessor",anchor:"transformers.Pix2StructImageProcessor",parameters:[{name:"do_convert_rgb",val:": bool = True"},{name:"do_normalize",val:": bool = True"},{name:"patch_size",val:": typing.Dict[str, int] = None"},{name:"max_patches",val:": int = 2048"},{name:"is_vqa",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Pix2StructImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method. According to Pix2Struct paper and code, the image is normalized with its own mean and standard
deviation.`,name:"do_normalize"},{anchor:"transformers.Pix2StructImageProcessor.patch_size",description:`<strong>patch_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 16, &quot;width&quot;: 16}</code>):
The patch size to use for the image. According to Pix2Struct paper and code, the patch size is 16x16.`,name:"patch_size"},{anchor:"transformers.Pix2StructImageProcessor.max_patches",description:`<strong>max_patches</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
The maximum number of patches to extract from the image as per the <a href="https://arxiv.org/pdf/2210.03347.pdf" rel="nofollow">Pix2Struct
paper</a>.`,name:"max_patches"},{anchor:"transformers.Pix2StructImageProcessor.is_vqa",description:`<strong>is_vqa</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the image processor is for the VQA task. If <code>True</code> and <code>header_text</code> is passed in, text is
rendered onto the input images.`,name:"is_vqa"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/image_processing_pix2struct.py#L187"}}),bt=new z({props:{name:"preprocess",anchor:"transformers.Pix2StructImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"header_text",val:": typing.Optional[str] = None"},{name:"do_convert_rgb",val:": bool = None"},{name:"do_normalize",val:": typing.Optional[bool] = None"},{name:"max_patches",val:": typing.Optional[int] = None"},{name:"patch_size",val:": typing.Union[typing.Dict[str, int], NoneType] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.Pix2StructImageProcessor.preprocess.header_text",description:`<strong>header_text</strong> (<code>Union[List[str], str]</code>, <em>optional</em>) &#x2014;
Text to render as a header. Only has an effect if <code>image_processor.is_vqa</code> is <code>True</code>.`,name:"header_text"},{anchor:"transformers.Pix2StructImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_convert_rgb</code>) &#x2014;
Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.Pix2StructImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.Pix2StructImageProcessor.preprocess.max_patches",description:`<strong>max_patches</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.max_patches</code>) &#x2014;
Maximum number of patches to extract.`,name:"max_patches"},{anchor:"transformers.Pix2StructImageProcessor.preprocess.patch_size",description:`<strong>patch_size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>self.patch_size</code>) &#x2014;
Dictionary containing the patch height and width.`,name:"patch_size"},{anchor:"transformers.Pix2StructImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/pix2struct/image_processing_pix2struct.py#L323"}}),yt=new A({}),Tt=new z({props:{name:"class transformers.Pix2StructTextModel",anchor:"transformers.Pix2StructTextModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructTextModel.config",description:`<strong>config</strong> (Union[<code>Pix2StructConfig</code>, <code>Pix2StructTextConfig</code>]) &#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.30.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.30.0/src/transformers/models/pix2struct/modeling_pix2struct.py#L1317"}}),$t=new z({props:{name:"forward",anchor:"transformers.Pix2StructTextModel.forward",parameters:[{name:"input_ids",val:" = None"},{name:"attention_mask",val:" = None"},{name:"encoder_hidden_states",val:" = None"},{name:"encoder_attention_mask",val:" = None"},{name:"inputs_embeds",val:" = None"},{name:"head_mask",val:" = None"},{name:"cross_attn_head_mask",val:" = None"},{name:"past_key_values",val:" = None"},{name:"use_cache",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"labels",val:" = None"},{name:"return_dict",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Pix2StructTextModel.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. Pix2StructText is a model with relative position
embeddings so you should be able to pad the inputs on both the right and the left.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for detail.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>To know more on how to prepare <code>input_ids</code> for pretraining take a look a <a href="./t5#training">Pix2StructText
Training</a>.`,name:"input_ids"},{anchor:"transformers.Pix2StructTextModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</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.Pix2StructTextModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>Pix2StructText uses the <code>pad_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. If
<code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>To know more on how to prepare <code>decoder_input_ids</code> for pretraining take a look at <a href="./t5#training">Pix2StructText
Training</a>.`,name:"decoder_input_ids"},{anchor:"transformers.Pix2StructTextModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</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.Pix2StructTextModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-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.Pix2StructTextModel.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-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.Pix2StructTextModel.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_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.Pix2StructTextModel.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>, <code>optional</code>: <em>hidden_states</em>, <code>optional</code>: <em>attentions</em>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code> 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.Pix2StructTextModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention layers. Can be used to speed up 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>.`,name:"past_key_values"},{anchor:"transformers.Pix2StructTextModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
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:"inputs_embeds"},{anchor:"transformers.Pix2StructTextModel.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.Pix2StructTextModel.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.Pix2StructTextModel.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.Pix2StructTextModel.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.Pix2StructTextModel.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.30.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.30.0/src/transformers/models/pix2struct/modeling_pix2struct.py#L1385",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</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.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig"
>Pix2StructConfig</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 (for next-token prediction).</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>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</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>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ue=new Bi({props:{$$slots:{default:[Pc]},$$scope:{ctx:k}}}),Ie=new At({props:{anchor:"transformers.Pix2StructTextModel.forward.example",$$slots:{default:[Mc]},$$scope:{ctx:k}}}),Jt=new A({}),Ct=new z({props:{name:"class transformers.Pix2StructVisionModel",anchor:"transformers.Pix2StructVisionModel",parameters:[{name:"config",val:": Pix2StructConfig"}],parametersDescription:[{anchor:"transformers.Pix2StructVisionModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig">Pix2StructConfig</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.30.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.30.0/src/transformers/models/pix2struct/modeling_pix2struct.py#L548"}}),Et=new z({props:{name:"forward",anchor:"transformers.Pix2StructVisionModel.forward",parameters:[{name:"flattened_patches",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = 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.Pix2StructVisionModel.forward.flattened_patches",description:`<strong>flattened_patches</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, num_channels x patch_height x patch_width)</code>) &#x2014;
Flattened and padded pixel values. These values can be obtained using <a href="/docs/transformers/v4.30.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<code>Pix2StructVisionImageProcessor.__call__</code> for details. Check the <a href="https://arxiv.org/abs/2210.03347" rel="nofollow">original
paper</a> (figure 5) for more details.`,name:"flattened_patches"},{anchor:"transformers.Pix2StructVisionModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding pixel values. Mask values selected in <code>[0, 1]</code>:`,name:"attention_mask"},{anchor:"transformers.Pix2StructVisionModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-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.Pix2StructVisionModel.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.Pix2StructVisionModel.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.Pix2StructVisionModel.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.30.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.30.0/src/transformers/models/pix2struct/modeling_pix2struct.py#L581",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</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.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig"
>Pix2StructConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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.30.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Fe=new Bi({props:{$$slots:{default:[kc]},$$scope:{ctx:k}}}),Ne=new At({props:{anchor:"transformers.Pix2StructVisionModel.forward.example",$$slots:{default:[Sc]},$$scope:{ctx:k}}}),Ut=new A({}),It=new z({props:{name:"class transformers.Pix2StructForConditionalGeneration",anchor:"transformers.Pix2StructForConditionalGeneration",parameters:[{name:"config",val:": Pix2StructConfig"}],parametersDescription:[{anchor:"transformers.Pix2StructForConditionalGeneration.config",description:`<strong>config</strong> (Union[<code>Pix2StructConfig</code>, <code>Pix2StructTextConfig</code>]) &#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.30.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.30.0/src/transformers/models/pix2struct/modeling_pix2struct.py#L1596"}}),Bt=new z({props:{name:"forward",anchor:"transformers.Pix2StructForConditionalGeneration.forward",parameters:[{name:"flattened_patches",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.Tensor] = 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.Pix2StructForConditionalGeneration.forward.flattened_patches",description:`<strong>flattened_patches</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, seq_length, hidden_size)</code>) &#x2014;
Flattened pixel patches. the <code>hidden_size</code> is obtained by the following formula: <code>hidden_size</code> =
<code>num_channels</code> <em> <code>patch_size</code> </em> <code>patch_size</code></p>
<p>The process of flattening the pixel patches is done by <code>Pix2StructProcessor</code>.`,name:"flattened_patches"},{anchor:"transformers.Pix2StructForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</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.Pix2StructForConditionalGeneration.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>Pix2StructText uses the <code>pad_token_id</code> as the starting token for <code>decoder_input_ids</code> generation. If
<code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>To know more on how to prepare <code>decoder_input_ids</code> for pretraining take a look at <a href="./t5#training">Pix2StructText
Training</a>.`,name:"decoder_input_ids"},{anchor:"transformers.Pix2StructForConditionalGeneration.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</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.Pix2StructForConditionalGeneration.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-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.Pix2StructForConditionalGeneration.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-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.Pix2StructForConditionalGeneration.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_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.Pix2StructForConditionalGeneration.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>, <code>optional</code>: <em>hidden_states</em>, <code>optional</code>: <em>attentions</em>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code> 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.Pix2StructForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention layers. Can be used to speed up 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>.`,name:"past_key_values"},{anchor:"transformers.Pix2StructForConditionalGeneration.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.Pix2StructForConditionalGeneration.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss for the decoder.`,name:"labels"},{anchor:"transformers.Pix2StructForConditionalGeneration.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.Pix2StructForConditionalGeneration.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.Pix2StructForConditionalGeneration.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.Pix2StructForConditionalGeneration.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.30.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.30.0/src/transformers/models/pix2struct/modeling_pix2struct.py#L1645",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqModelOutput"
>transformers.modeling_outputs.Seq2SeqModelOutput</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.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig"
>Pix2StructConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the decoder of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</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 optional 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 optional 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.30.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqModelOutput"
>transformers.modeling_outputs.Seq2SeqModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ze=new Bi({props:{$$slots:{default:[$c]},$$scope:{ctx:k}}}),Be=new At({props:{anchor:"transformers.Pix2StructForConditionalGeneration.forward.example",$$slots:{default:[Jc]},$$scope:{ctx:k}}}),Re=new At({props:{anchor:"transformers.Pix2StructForConditionalGeneration.forward.example-2",$$slots:{default:[Cc]},$$scope:{ctx:k}}}),{c(){u=n("meta"),b=d(),_=n("h1"),m=n("a"),v=n("span"),x(l.$$.fragment),f=d(),E=n("span"),yr=a("Pix2Struct"),wn=d(),O=n("h2"),ge=n("a"),Eo=n("span"),x(He.$$.fragment),Tr=d(),Uo=n("span"),wr=a("Overview"),Pn=d(),_e=n("p"),Pr=a("The Pix2Struct model was proposed in "),Ye=n("a"),Mr=a("Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding"),kr=a(" by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu, Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, Kristina Toutanova."),Mn=d(),Dt=n("p"),Sr=a("The abstract from the paper is the following:"),kn=d(),Qt=n("blockquote"),Io=n("p"),$r=a("Visually-situated language is ubiquitous \u2014 sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and forms. Perhaps due to this diversity, previous work has typically relied on domain-specific recipes with limited sharing of the underlying data, model architectures, and objectives. We present Pix2Struct, a pretrained image-to-text model for purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse masked screenshots of web pages into simplified HTML. The web, with its richness of visual elements cleanly reflected in the HTML structure, provides a large source of pretraining data well suited to the diversity of downstream tasks. Intuitively, this objective subsumes common pretraining signals such as OCR, language modeling, image captioning. In addition to the novel pretraining strategy, we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions are rendered directly on top of the input image. For the first time, we show that a single pretrained model can achieve state-of-the-art results in six out of nine tasks across four domains: documents, illustrations, user interfaces, and natural images."),Sn=d(),Lt=n("p"),Jr=a("Tips:"),$n=d(),Ot=n("p"),Cr=a(`Pix2Struct has been fine tuned on a variety of tasks and datasets, ranging from image captioning, visual question answering (VQA) over different inputs (books, charts, science diagrams), captioning UI components etc. The full list can be found in Table 1 of the paper.
We therefore advise you to use these models for the tasks they have been fine tuned on. For instance, if you want to use Pix2Struct for UI captioning, you should use the model fine tuned on the UI dataset. If you want to use Pix2Struct for image captioning, you should use the model fine tuned on the natural images captioning dataset and so on.`),Jn=d(),ve=n("p"),jr=a("If you want to use the model to perform conditional text captioning, make sure to use the processor with "),Wo=n("code"),zr=a("add_special_tokens=False"),Er=a("."),Cn=d(),H=n("p"),Ur=a("This model was contributed by "),De=n("a"),Ir=a("ybelkada"),Wr=a(`.
The original code can be found `),Qe=n("a"),Fr=a("here"),Nr=a("."),jn=d(),K=n("h2"),be=n("a"),Fo=n("span"),x(Le.$$.fragment),Vr=d(),No=n("span"),Zr=a("Resources"),zn=d(),xe=n("ul"),Vo=n("li"),Oe=n("a"),Br=a("Fine-tuning Notebook"),Rr=d(),Zo=n("li"),Ke=n("a"),Gr=a("All models"),En=d(),ee=n("h2"),ye=n("a"),Bo=n("span"),x(et.$$.fragment),qr=d(),Ro=n("span"),Xr=a("Pix2StructConfig"),Un=d(),C=n("div"),x(tt.$$.fragment),Ar=d(),Y=n("p"),Kt=n("a"),Hr=a("Pix2StructConfig"),Yr=a(` is the configuration class to store the configuration of a
`),eo=n("a"),Dr=a("Pix2StructForConditionalGeneration"),Qr=a(`. It is used to instantiate a Pix2Struct model according to the specified
arguments, defining the text model and vision model configs. Instantiating a configuration with the defaults will
yield a similar configuration to that of the Pix2Struct-base
`),ot=n("a"),Lr=a("google/pix2struct-base"),Or=a(" architecture."),Kr=d(),te=n("p"),es=a("Configuration objects inherit from "),to=n("a"),ts=a("PretrainedConfig"),os=a(` and can be used to control the model outputs. Read the
documentation from `),oo=n("a"),ns=a("PretrainedConfig"),rs=a(" for more information."),ss=d(),x(Te.$$.fragment),as=d(),we=n("div"),x(nt.$$.fragment),is=d(),rt=n("p"),ls=a("Instantiate a "),no=n("a"),cs=a("Pix2StructConfig"),ds=a(` (or a derived class) from pix2struct text model configuration and pix2struct
vision model configuration.`),In=d(),oe=n("h2"),Pe=n("a"),Go=n("span"),x(st.$$.fragment),ps=d(),qo=n("span"),us=a("Pix2StructTextConfig"),Wn=d(),I=n("div"),x(at.$$.fragment),hs=d(),ne=n("p"),ms=a("This is the configuration class to store the configuration of a "),ro=n("a"),fs=a("Pix2StructTextModel"),gs=a(`. It is used to instantiate
a Pix2Struct text model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the Pix2Struct text decoder used by
the `),it=n("a"),_s=a("google/pix2struct-base"),vs=a(" architecture."),bs=d(),re=n("p"),xs=a("Configuration objects inherit from "),so=n("a"),ys=a("PretrainedConfig"),Ts=a(` and can be used to control the model outputs. Read the
documentation from `),ao=n("a"),ws=a("PretrainedConfig"),Ps=a(" for more information."),Ms=d(),x(Me.$$.fragment),Fn=d(),se=n("h2"),ke=n("a"),Xo=n("span"),x(lt.$$.fragment),ks=d(),Ao=n("span"),Ss=a("Pix2StructVisionConfig"),Nn=d(),W=n("div"),x(ct.$$.fragment),$s=d(),ae=n("p"),Js=a("This is the configuration class to store the configuration of a "),io=n("a"),Cs=a("Pix2StructVisionModel"),js=a(`. It is used to
instantiate a Pix2Struct vision model according to the specified arguments, defining the model architecture.
Instantiating a configuration defaults will yield a similar configuration to that of the Pix2Struct-base
`),dt=n("a"),zs=a("google/pix2struct-base"),Es=a(" architecture."),Us=d(),ie=n("p"),Is=a("Configuration objects inherit from "),lo=n("a"),Ws=a("PretrainedConfig"),Fs=a(` and can be used to control the model outputs. Read the
documentation from `),co=n("a"),Ns=a("PretrainedConfig"),Vs=a(" for more information."),Zs=d(),x(Se.$$.fragment),Vn=d(),le=n("h2"),$e=n("a"),Ho=n("span"),x(pt.$$.fragment),Bs=d(),Yo=n("span"),Rs=a("Pix2StructProcessor"),Zn=d(),j=n("div"),x(ut.$$.fragment),Gs=d(),Do=n("p"),qs=a(`Constructs a PIX2STRUCT processor which wraps a BERT tokenizer and PIX2STRUCT image processor into a single
processor.`),Xs=d(),U=n("p"),po=n("a"),As=a("Pix2StructProcessor"),Hs=a(" offers all the functionalities of "),uo=n("a"),Ys=a("Pix2StructImageProcessor"),Ds=a(" and "),ho=n("a"),Qs=a("T5TokenizerFast"),Ls=a(`. See
the docstring of `),Qo=n("code"),Os=a("__call__()"),Ks=a(" and "),mo=n("a"),ea=a("decode()"),ta=a(" for more information."),oa=d(),Je=n("div"),x(ht.$$.fragment),na=d(),mt=n("p"),ra=a("This method forwards all its arguments to Pix2StructTokenizerFast\u2019s "),fo=n("a"),sa=a("batch_decode()"),aa=a(`.
Please refer to the docstring of this method for more information.`),ia=d(),Ce=n("div"),x(ft.$$.fragment),la=d(),gt=n("p"),ca=a("This method forwards all its arguments to Pix2StructTokenizerFast\u2019s "),go=n("a"),da=a("decode()"),pa=a(`. Please
refer to the docstring of this method for more information.`),Bn=d(),ce=n("h2"),je=n("a"),Lo=n("span"),x(_t.$$.fragment),ua=d(),Oo=n("span"),ha=a("Pix2StructImageProcessor"),Rn=d(),G=n("div"),x(vt.$$.fragment),ma=d(),Ko=n("p"),fa=a("Constructs a Pix2Struct image processor."),ga=d(),ze=n("div"),x(bt.$$.fragment),_a=d(),F=n("p"),va=a(`Preprocess an image or batch of images. The processor first computes the maximum possible number of
aspect-ratio preserving patches of size `),en=n("code"),ba=a("patch_size"),xa=a(` that can be extracted from the image. It then pads the
image with zeros to make the image respect the constraint of `),tn=n("code"),ya=a("max_patches"),Ta=a(`. Before extracting the patches the
images are standardized following the tensorflow implementation of `),on=n("code"),wa=a("per_image_standardization"),Pa=a(`
(`),xt=n("a"),Ma=a("https://www.tensorflow.org/api_docs/python/tf/image/per_image_standardization"),ka=a(")."),Gn=d(),de=n("h2"),Ee=n("a"),nn=n("span"),x(yt.$$.fragment),Sa=d(),rn=n("span"),$a=a("Pix2StructTextModel"),qn=d(),S=n("div"),x(Tt.$$.fragment),Ja=d(),sn=n("p"),Ca=a("The standalone text decoder of Pix2Struct"),ja=d(),wt=n("p"),za=a("The Pix2Struct model was proposed in "),Pt=n("a"),Ea=a(`Pix2Struct: Screenshot Parsing as Pretraining for Visual Language
Understanding`),Ua=a(` by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu,
Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, Kristina Toutanova. It\u2019s an encoder decoder
transformer pre-trained in a image-to-text setting.`),Ia=d(),Mt=n("p"),Wa=a("This model inherits from "),_o=n("a"),Fa=a("PreTrainedModel"),Na=a(`. 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.)`),Va=d(),kt=n("p"),Za=a("This model is also a PyTorch "),St=n("a"),Ba=a("torch.nn.Module"),Ra=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ga=d(),N=n("div"),x($t.$$.fragment),qa=d(),pe=n("p"),Xa=a("The "),vo=n("a"),Aa=a("Pix2StructTextModel"),Ha=a(" forward method, overrides the "),an=n("code"),Ya=a("__call__"),Da=a(" special method."),Qa=d(),x(Ue.$$.fragment),La=d(),x(Ie.$$.fragment),Xn=d(),ue=n("h2"),We=n("a"),ln=n("span"),x(Jt.$$.fragment),Oa=d(),cn=n("span"),Ka=a("Pix2StructVisionModel"),An=d(),q=n("div"),x(Ct.$$.fragment),ei=d(),jt=n("p"),ti=a(`The bare Pix2StructVision Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),zt=n("a"),oi=a("torch.nn.Module"),ni=a(` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ri=d(),V=n("div"),x(Et.$$.fragment),si=d(),he=n("p"),ai=a("The "),bo=n("a"),ii=a("Pix2StructVisionModel"),li=a(" forward method, overrides the "),dn=n("code"),ci=a("__call__"),di=a(" special method."),pi=d(),x(Fe.$$.fragment),ui=d(),x(Ne.$$.fragment),Hn=d(),me=n("h2"),Ve=n("a"),pn=n("span"),x(Ut.$$.fragment),hi=d(),un=n("span"),mi=a("Pix2StructForConditionalGeneration"),Yn=d(),$=n("div"),x(It.$$.fragment),fi=d(),hn=n("p"),gi=a("A conditional generation model with a language modeling head. Can be used for sequence generation tasks."),_i=d(),Wt=n("p"),vi=a("The Pix2Struct model was proposed in "),Ft=n("a"),bi=a(`Pix2Struct: Screenshot Parsing as Pretraining for Visual Language
Understanding`),xi=a(` by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu,
Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, Kristina Toutanova. It\u2019s an encoder decoder
transformer pre-trained in a image-to-text setting.`),yi=d(),Nt=n("p"),Ti=a("This model inherits from "),xo=n("a"),wi=a("PreTrainedModel"),Pi=a(`. 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.)`),Mi=d(),Vt=n("p"),ki=a("This model is also a PyTorch "),Zt=n("a"),Si=a("torch.nn.Module"),$i=a(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ji=d(),J=n("div"),x(Bt.$$.fragment),Ci=d(),fe=n("p"),ji=a("The "),yo=n("a"),zi=a("Pix2StructForConditionalGeneration"),Ei=a(" forward method, overrides the "),mn=n("code"),Ui=a("__call__"),Ii=a(" special method."),Wi=d(),x(Ze.$$.fragment),Fi=d(),fn=n("p"),Ni=a("Example:"),Vi=d(),x(Be.$$.fragment),Zi=d(),x(Re.$$.fragment),this.h()},l(t){const h=bc('[data-svelte="svelte-1phssyn"]',document.head);u=r(h,"META",{name:!0,content:!0}),h.forEach(o),b=p(t),_=r(t,"H1",{class:!0});var Rt=s(_);m=r(Rt,"A",{id:!0,class:!0,href:!0});var gn=s(m);v=r(gn,"SPAN",{});var _n=s(v);y(l.$$.fragment,_n),_n.forEach(o),gn.forEach(o),f=p(Rt),E=r(Rt,"SPAN",{});var vn=s(E);yr=i(vn,"Pix2Struct"),vn.forEach(o),Rt.forEach(o),wn=p(t),O=r(t,"H2",{class:!0});var Gt=s(O);ge=r(Gt,"A",{id:!0,class:!0,href:!0});var bn=s(ge);Eo=r(bn,"SPAN",{});var xn=s(Eo);y(He.$$.fragment,xn),xn.forEach(o),bn.forEach(o),Tr=p(Gt),Uo=r(Gt,"SPAN",{});var yn=s(Uo);wr=i(yn,"Overview"),yn.forEach(o),Gt.forEach(o),Pn=p(t),_e=r(t,"P",{});var qt=s(_e);Pr=i(qt,"The Pix2Struct model was proposed in "),Ye=r(qt,"A",{href:!0,rel:!0});var Tn=s(Ye);Mr=i(Tn,"Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding"),Tn.forEach(o),kr=i(qt," by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu, Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, Kristina Toutanova."),qt.forEach(o),Mn=p(t),Dt=r(t,"P",{});var Ri=s(Dt);Sr=i(Ri,"The abstract from the paper is the following:"),Ri.forEach(o),kn=p(t),Qt=r(t,"BLOCKQUOTE",{});var Gi=s(Qt);Io=r(Gi,"P",{});var qi=s(Io);$r=i(qi,"Visually-situated language is ubiquitous \u2014 sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and forms. Perhaps due to this diversity, previous work has typically relied on domain-specific recipes with limited sharing of the underlying data, model architectures, and objectives. We present Pix2Struct, a pretrained image-to-text model for purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse masked screenshots of web pages into simplified HTML. The web, with its richness of visual elements cleanly reflected in the HTML structure, provides a large source of pretraining data well suited to the diversity of downstream tasks. Intuitively, this objective subsumes common pretraining signals such as OCR, language modeling, image captioning. In addition to the novel pretraining strategy, we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions are rendered directly on top of the input image. For the first time, we show that a single pretrained model can achieve state-of-the-art results in six out of nine tasks across four domains: documents, illustrations, user interfaces, and natural images."),qi.forEach(o),Gi.forEach(o),Sn=p(t),Lt=r(t,"P",{});var Xi=s(Lt);Jr=i(Xi,"Tips:"),Xi.forEach(o),$n=p(t),Ot=r(t,"P",{});var Ai=s(Ot);Cr=i(Ai,`Pix2Struct has been fine tuned on a variety of tasks and datasets, ranging from image captioning, visual question answering (VQA) over different inputs (books, charts, science diagrams), captioning UI components etc. The full list can be found in Table 1 of the paper.
We therefore advise you to use these models for the tasks they have been fine tuned on. For instance, if you want to use Pix2Struct for UI captioning, you should use the model fine tuned on the UI dataset. If you want to use Pix2Struct for image captioning, you should use the model fine tuned on the natural images captioning dataset and so on.`),Ai.forEach(o),Jn=p(t),ve=r(t,"P",{});var Qn=s(ve);jr=i(Qn,"If you want to use the model to perform conditional text captioning, make sure to use the processor with "),Wo=r(Qn,"CODE",{});var Hi=s(Wo);zr=i(Hi,"add_special_tokens=False"),Hi.forEach(o),Er=i(Qn,"."),Qn.forEach(o),Cn=p(t),H=r(t,"P",{});var To=s(H);Ur=i(To,"This model was contributed by "),De=r(To,"A",{href:!0,rel:!0});var Yi=s(De);Ir=i(Yi,"ybelkada"),Yi.forEach(o),Wr=i(To,`.
The original code can be found `),Qe=r(To,"A",{href:!0,rel:!0});var Di=s(Qe);Fr=i(Di,"here"),Di.forEach(o),Nr=i(To,"."),To.forEach(o),jn=p(t),K=r(t,"H2",{class:!0});var Ln=s(K);be=r(Ln,"A",{id:!0,class:!0,href:!0});var Qi=s(be);Fo=r(Qi,"SPAN",{});var Li=s(Fo);y(Le.$$.fragment,Li),Li.forEach(o),Qi.forEach(o),Vr=p(Ln),No=r(Ln,"SPAN",{});var Oi=s(No);Zr=i(Oi,"Resources"),Oi.forEach(o),Ln.forEach(o),zn=p(t),xe=r(t,"UL",{});var On=s(xe);Vo=r(On,"LI",{});var Ki=s(Vo);Oe=r(Ki,"A",{href:!0,rel:!0});var el=s(Oe);Br=i(el,"Fine-tuning Notebook"),el.forEach(o),Ki.forEach(o),Rr=p(On),Zo=r(On,"LI",{});var tl=s(Zo);Ke=r(tl,"A",{href:!0,rel:!0});var ol=s(Ke);Gr=i(ol,"All models"),ol.forEach(o),tl.forEach(o),On.forEach(o),En=p(t),ee=r(t,"H2",{class:!0});var Kn=s(ee);ye=r(Kn,"A",{id:!0,class:!0,href:!0});var nl=s(ye);Bo=r(nl,"SPAN",{});var rl=s(Bo);y(et.$$.fragment,rl),rl.forEach(o),nl.forEach(o),qr=p(Kn),Ro=r(Kn,"SPAN",{});var sl=s(Ro);Xr=i(sl,"Pix2StructConfig"),sl.forEach(o),Kn.forEach(o),Un=p(t),C=r(t,"DIV",{class:!0});var D=s(C);y(tt.$$.fragment,D),Ar=p(D),Y=r(D,"P",{});var Xt=s(Y);Kt=r(Xt,"A",{href:!0});var al=s(Kt);Hr=i(al,"Pix2StructConfig"),al.forEach(o),Yr=i(Xt,` is the configuration class to store the configuration of a
`),eo=r(Xt,"A",{href:!0});var il=s(eo);Dr=i(il,"Pix2StructForConditionalGeneration"),il.forEach(o),Qr=i(Xt,`. It is used to instantiate a Pix2Struct model according to the specified
arguments, defining the text model and vision model configs. Instantiating a configuration with the defaults will
yield a similar configuration to that of the Pix2Struct-base
`),ot=r(Xt,"A",{href:!0,rel:!0});var ll=s(ot);Lr=i(ll,"google/pix2struct-base"),ll.forEach(o),Or=i(Xt," architecture."),Xt.forEach(o),Kr=p(D),te=r(D,"P",{});var wo=s(te);es=i(wo,"Configuration objects inherit from "),to=r(wo,"A",{href:!0});var cl=s(to);ts=i(cl,"PretrainedConfig"),cl.forEach(o),os=i(wo,` and can be used to control the model outputs. Read the
documentation from `),oo=r(wo,"A",{href:!0});var dl=s(oo);ns=i(dl,"PretrainedConfig"),dl.forEach(o),rs=i(wo," for more information."),wo.forEach(o),ss=p(D),y(Te.$$.fragment,D),as=p(D),we=r(D,"DIV",{class:!0});var er=s(we);y(nt.$$.fragment,er),is=p(er),rt=r(er,"P",{});var tr=s(rt);ls=i(tr,"Instantiate a "),no=r(tr,"A",{href:!0});var pl=s(no);cs=i(pl,"Pix2StructConfig"),pl.forEach(o),ds=i(tr,` (or a derived class) from pix2struct text model configuration and pix2struct
vision model configuration.`),tr.forEach(o),er.forEach(o),D.forEach(o),In=p(t),oe=r(t,"H2",{class:!0});var or=s(oe);Pe=r(or,"A",{id:!0,class:!0,href:!0});var ul=s(Pe);Go=r(ul,"SPAN",{});var hl=s(Go);y(st.$$.fragment,hl),hl.forEach(o),ul.forEach(o),ps=p(or),qo=r(or,"SPAN",{});var ml=s(qo);us=i(ml,"Pix2StructTextConfig"),ml.forEach(o),or.forEach(o),Wn=p(t),I=r(t,"DIV",{class:!0});var Ge=s(I);y(at.$$.fragment,Ge),hs=p(Ge),ne=r(Ge,"P",{});var Po=s(ne);ms=i(Po,"This is the configuration class to store the configuration of a "),ro=r(Po,"A",{href:!0});var fl=s(ro);fs=i(fl,"Pix2StructTextModel"),fl.forEach(o),gs=i(Po,`. It is used to instantiate
a Pix2Struct text model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the Pix2Struct text decoder used by
the `),it=r(Po,"A",{href:!0,rel:!0});var gl=s(it);_s=i(gl,"google/pix2struct-base"),gl.forEach(o),vs=i(Po," architecture."),Po.forEach(o),bs=p(Ge),re=r(Ge,"P",{});var Mo=s(re);xs=i(Mo,"Configuration objects inherit from "),so=r(Mo,"A",{href:!0});var _l=s(so);ys=i(_l,"PretrainedConfig"),_l.forEach(o),Ts=i(Mo,` and can be used to control the model outputs. Read the
documentation from `),ao=r(Mo,"A",{href:!0});var vl=s(ao);ws=i(vl,"PretrainedConfig"),vl.forEach(o),Ps=i(Mo," for more information."),Mo.forEach(o),Ms=p(Ge),y(Me.$$.fragment,Ge),Ge.forEach(o),Fn=p(t),se=r(t,"H2",{class:!0});var nr=s(se);ke=r(nr,"A",{id:!0,class:!0,href:!0});var bl=s(ke);Xo=r(bl,"SPAN",{});var xl=s(Xo);y(lt.$$.fragment,xl),xl.forEach(o),bl.forEach(o),ks=p(nr),Ao=r(nr,"SPAN",{});var yl=s(Ao);Ss=i(yl,"Pix2StructVisionConfig"),yl.forEach(o),nr.forEach(o),Nn=p(t),W=r(t,"DIV",{class:!0});var qe=s(W);y(ct.$$.fragment,qe),$s=p(qe),ae=r(qe,"P",{});var ko=s(ae);Js=i(ko,"This is the configuration class to store the configuration of a "),io=r(ko,"A",{href:!0});var Tl=s(io);Cs=i(Tl,"Pix2StructVisionModel"),Tl.forEach(o),js=i(ko,`. It is used to
instantiate a Pix2Struct vision model according to the specified arguments, defining the model architecture.
Instantiating a configuration defaults will yield a similar configuration to that of the Pix2Struct-base
`),dt=r(ko,"A",{href:!0,rel:!0});var wl=s(dt);zs=i(wl,"google/pix2struct-base"),wl.forEach(o),Es=i(ko," architecture."),ko.forEach(o),Us=p(qe),ie=r(qe,"P",{});var So=s(ie);Is=i(So,"Configuration objects inherit from "),lo=r(So,"A",{href:!0});var Pl=s(lo);Ws=i(Pl,"PretrainedConfig"),Pl.forEach(o),Fs=i(So,` and can be used to control the model outputs. Read the
documentation from `),co=r(So,"A",{href:!0});var Ml=s(co);Ns=i(Ml,"PretrainedConfig"),Ml.forEach(o),Vs=i(So," for more information."),So.forEach(o),Zs=p(qe),y(Se.$$.fragment,qe),qe.forEach(o),Vn=p(t),le=r(t,"H2",{class:!0});var rr=s(le);$e=r(rr,"A",{id:!0,class:!0,href:!0});var kl=s($e);Ho=r(kl,"SPAN",{});var Sl=s(Ho);y(pt.$$.fragment,Sl),Sl.forEach(o),kl.forEach(o),Bs=p(rr),Yo=r(rr,"SPAN",{});var $l=s(Yo);Rs=i($l,"Pix2StructProcessor"),$l.forEach(o),rr.forEach(o),Zn=p(t),j=r(t,"DIV",{class:!0});var Q=s(j);y(ut.$$.fragment,Q),Gs=p(Q),Do=r(Q,"P",{});var Jl=s(Do);qs=i(Jl,`Constructs a PIX2STRUCT processor which wraps a BERT tokenizer and PIX2STRUCT image processor into a single
processor.`),Jl.forEach(o),Xs=p(Q),U=r(Q,"P",{});var X=s(U);po=r(X,"A",{href:!0});var Cl=s(po);As=i(Cl,"Pix2StructProcessor"),Cl.forEach(o),Hs=i(X," offers all the functionalities of "),uo=r(X,"A",{href:!0});var jl=s(uo);Ys=i(jl,"Pix2StructImageProcessor"),jl.forEach(o),Ds=i(X," and "),ho=r(X,"A",{href:!0});var zl=s(ho);Qs=i(zl,"T5TokenizerFast"),zl.forEach(o),Ls=i(X,`. See
the docstring of `),Qo=r(X,"CODE",{});var El=s(Qo);Os=i(El,"__call__()"),El.forEach(o),Ks=i(X," and "),mo=r(X,"A",{href:!0});var Ul=s(mo);ea=i(Ul,"decode()"),Ul.forEach(o),ta=i(X," for more information."),X.forEach(o),oa=p(Q),Je=r(Q,"DIV",{class:!0});var sr=s(Je);y(ht.$$.fragment,sr),na=p(sr),mt=r(sr,"P",{});var ar=s(mt);ra=i(ar,"This method forwards all its arguments to Pix2StructTokenizerFast\u2019s "),fo=r(ar,"A",{href:!0});var Il=s(fo);sa=i(Il,"batch_decode()"),Il.forEach(o),aa=i(ar,`.
Please refer to the docstring of this method for more information.`),ar.forEach(o),sr.forEach(o),ia=p(Q),Ce=r(Q,"DIV",{class:!0});var ir=s(Ce);y(ft.$$.fragment,ir),la=p(ir),gt=r(ir,"P",{});var lr=s(gt);ca=i(lr,"This method forwards all its arguments to Pix2StructTokenizerFast\u2019s "),go=r(lr,"A",{href:!0});var Wl=s(go);da=i(Wl,"decode()"),Wl.forEach(o),pa=i(lr,`. Please
refer to the docstring of this method for more information.`),lr.forEach(o),ir.forEach(o),Q.forEach(o),Bn=p(t),ce=r(t,"H2",{class:!0});var cr=s(ce);je=r(cr,"A",{id:!0,class:!0,href:!0});var Fl=s(je);Lo=r(Fl,"SPAN",{});var Nl=s(Lo);y(_t.$$.fragment,Nl),Nl.forEach(o),Fl.forEach(o),ua=p(cr),Oo=r(cr,"SPAN",{});var Vl=s(Oo);ha=i(Vl,"Pix2StructImageProcessor"),Vl.forEach(o),cr.forEach(o),Rn=p(t),G=r(t,"DIV",{class:!0});var $o=s(G);y(vt.$$.fragment,$o),ma=p($o),Ko=r($o,"P",{});var Zl=s(Ko);fa=i(Zl,"Constructs a Pix2Struct image processor."),Zl.forEach(o),ga=p($o),ze=r($o,"DIV",{class:!0});var dr=s(ze);y(bt.$$.fragment,dr),_a=p(dr),F=r(dr,"P",{});var L=s(F);va=i(L,`Preprocess an image or batch of images. The processor first computes the maximum possible number of
aspect-ratio preserving patches of size `),en=r(L,"CODE",{});var Bl=s(en);ba=i(Bl,"patch_size"),Bl.forEach(o),xa=i(L,` that can be extracted from the image. It then pads the
image with zeros to make the image respect the constraint of `),tn=r(L,"CODE",{});var Rl=s(tn);ya=i(Rl,"max_patches"),Rl.forEach(o),Ta=i(L,`. Before extracting the patches the
images are standardized following the tensorflow implementation of `),on=r(L,"CODE",{});var Gl=s(on);wa=i(Gl,"per_image_standardization"),Gl.forEach(o),Pa=i(L,`
(`),xt=r(L,"A",{href:!0,rel:!0});var ql=s(xt);Ma=i(ql,"https://www.tensorflow.org/api_docs/python/tf/image/per_image_standardization"),ql.forEach(o),ka=i(L,")."),L.forEach(o),dr.forEach(o),$o.forEach(o),Gn=p(t),de=r(t,"H2",{class:!0});var pr=s(de);Ee=r(pr,"A",{id:!0,class:!0,href:!0});var Xl=s(Ee);nn=r(Xl,"SPAN",{});var Al=s(nn);y(yt.$$.fragment,Al),Al.forEach(o),Xl.forEach(o),Sa=p(pr),rn=r(pr,"SPAN",{});var Hl=s(rn);$a=i(Hl,"Pix2StructTextModel"),Hl.forEach(o),pr.forEach(o),qn=p(t),S=r(t,"DIV",{class:!0});var Z=s(S);y(Tt.$$.fragment,Z),Ja=p(Z),sn=r(Z,"P",{});var Yl=s(sn);Ca=i(Yl,"The standalone text decoder of Pix2Struct"),Yl.forEach(o),ja=p(Z),wt=r(Z,"P",{});var ur=s(wt);za=i(ur,"The Pix2Struct model was proposed in "),Pt=r(ur,"A",{href:!0,rel:!0});var Dl=s(Pt);Ea=i(Dl,`Pix2Struct: Screenshot Parsing as Pretraining for Visual Language
Understanding`),Dl.forEach(o),Ua=i(ur,` by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu,
Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, Kristina Toutanova. It\u2019s an encoder decoder
transformer pre-trained in a image-to-text setting.`),ur.forEach(o),Ia=p(Z),Mt=r(Z,"P",{});var hr=s(Mt);Wa=i(hr,"This model inherits from "),_o=r(hr,"A",{href:!0});var Ql=s(_o);Fa=i(Ql,"PreTrainedModel"),Ql.forEach(o),Na=i(hr,`. 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.)`),hr.forEach(o),Va=p(Z),kt=r(Z,"P",{});var mr=s(kt);Za=i(mr,"This model is also a PyTorch "),St=r(mr,"A",{href:!0,rel:!0});var Ll=s(St);Ba=i(Ll,"torch.nn.Module"),Ll.forEach(o),Ra=i(mr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),mr.forEach(o),Ga=p(Z),N=r(Z,"DIV",{class:!0});var Xe=s(N);y($t.$$.fragment,Xe),qa=p(Xe),pe=r(Xe,"P",{});var Jo=s(pe);Xa=i(Jo,"The "),vo=r(Jo,"A",{href:!0});var Ol=s(vo);Aa=i(Ol,"Pix2StructTextModel"),Ol.forEach(o),Ha=i(Jo," forward method, overrides the "),an=r(Jo,"CODE",{});var Kl=s(an);Ya=i(Kl,"__call__"),Kl.forEach(o),Da=i(Jo," special method."),Jo.forEach(o),Qa=p(Xe),y(Ue.$$.fragment,Xe),La=p(Xe),y(Ie.$$.fragment,Xe),Xe.forEach(o),Z.forEach(o),Xn=p(t),ue=r(t,"H2",{class:!0});var fr=s(ue);We=r(fr,"A",{id:!0,class:!0,href:!0});var ec=s(We);ln=r(ec,"SPAN",{});var tc=s(ln);y(Jt.$$.fragment,tc),tc.forEach(o),ec.forEach(o),Oa=p(fr),cn=r(fr,"SPAN",{});var oc=s(cn);Ka=i(oc,"Pix2StructVisionModel"),oc.forEach(o),fr.forEach(o),An=p(t),q=r(t,"DIV",{class:!0});var Co=s(q);y(Ct.$$.fragment,Co),ei=p(Co),jt=r(Co,"P",{});var gr=s(jt);ti=i(gr,`The bare Pix2StructVision Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),zt=r(gr,"A",{href:!0,rel:!0});var nc=s(zt);oi=i(nc,"torch.nn.Module"),nc.forEach(o),ni=i(gr,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),gr.forEach(o),ri=p(Co),V=r(Co,"DIV",{class:!0});var Ae=s(V);y(Et.$$.fragment,Ae),si=p(Ae),he=r(Ae,"P",{});var jo=s(he);ai=i(jo,"The "),bo=r(jo,"A",{href:!0});var rc=s(bo);ii=i(rc,"Pix2StructVisionModel"),rc.forEach(o),li=i(jo," forward method, overrides the "),dn=r(jo,"CODE",{});var sc=s(dn);ci=i(sc,"__call__"),sc.forEach(o),di=i(jo," special method."),jo.forEach(o),pi=p(Ae),y(Fe.$$.fragment,Ae),ui=p(Ae),y(Ne.$$.fragment,Ae),Ae.forEach(o),Co.forEach(o),Hn=p(t),me=r(t,"H2",{class:!0});var _r=s(me);Ve=r(_r,"A",{id:!0,class:!0,href:!0});var ac=s(Ve);pn=r(ac,"SPAN",{});var ic=s(pn);y(Ut.$$.fragment,ic),ic.forEach(o),ac.forEach(o),hi=p(_r),un=r(_r,"SPAN",{});var lc=s(un);mi=i(lc,"Pix2StructForConditionalGeneration"),lc.forEach(o),_r.forEach(o),Yn=p(t),$=r(t,"DIV",{class:!0});var B=s($);y(It.$$.fragment,B),fi=p(B),hn=r(B,"P",{});var cc=s(hn);gi=i(cc,"A conditional generation model with a language modeling head. Can be used for sequence generation tasks."),cc.forEach(o),_i=p(B),Wt=r(B,"P",{});var vr=s(Wt);vi=i(vr,"The Pix2Struct model was proposed in "),Ft=r(vr,"A",{href:!0,rel:!0});var dc=s(Ft);bi=i(dc,`Pix2Struct: Screenshot Parsing as Pretraining for Visual Language
Understanding`),dc.forEach(o),xi=i(vr,` by Kenton Lee, Mandar Joshi, Iulia Turc, Hexiang Hu, Fangyu Liu,
Julian Eisenschlos, Urvashi Khandelwal, Peter Shaw, Ming-Wei Chang, Kristina Toutanova. It\u2019s an encoder decoder
transformer pre-trained in a image-to-text setting.`),vr.forEach(o),yi=p(B),Nt=r(B,"P",{});var br=s(Nt);Ti=i(br,"This model inherits from "),xo=r(br,"A",{href:!0});var pc=s(xo);wi=i(pc,"PreTrainedModel"),pc.forEach(o),Pi=i(br,`. 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.)`),br.forEach(o),Mi=p(B),Vt=r(B,"P",{});var xr=s(Vt);ki=i(xr,"This model is also a PyTorch "),Zt=r(xr,"A",{href:!0,rel:!0});var uc=s(Zt);Si=i(uc,"torch.nn.Module"),uc.forEach(o),$i=i(xr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),xr.forEach(o),Ji=p(B),J=r(B,"DIV",{class:!0});var R=s(J);y(Bt.$$.fragment,R),Ci=p(R),fe=r(R,"P",{});var zo=s(fe);ji=i(zo,"The "),yo=r(zo,"A",{href:!0});var hc=s(yo);zi=i(hc,"Pix2StructForConditionalGeneration"),hc.forEach(o),Ei=i(zo," forward method, overrides the "),mn=r(zo,"CODE",{});var mc=s(mn);Ui=i(mc,"__call__"),mc.forEach(o),Ii=i(zo," special method."),zo.forEach(o),Wi=p(R),y(Ze.$$.fragment,R),Fi=p(R),fn=r(R,"P",{});var fc=s(fn);Ni=i(fc,"Example:"),fc.forEach(o),Vi=p(R),y(Be.$$.fragment,R),Zi=p(R),y(Re.$$.fragment,R),R.forEach(o),B.forEach(o),this.h()},h(){c(u,"name","hf:doc:metadata"),c(u,"content",JSON.stringify(zc)),c(m,"id","pix2struct"),c(m,"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"),c(m,"href","#pix2struct"),c(_,"class","relative group"),c(ge,"id","overview"),c(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"),c(ge,"href","#overview"),c(O,"class","relative group"),c(Ye,"href","https://arxiv.org/abs/2210.03347"),c(Ye,"rel","nofollow"),c(De,"href","https://huggingface.co/ybelkada"),c(De,"rel","nofollow"),c(Qe,"href","https://github.com/google-research/pix2struct"),c(Qe,"rel","nofollow"),c(be,"id","resources"),c(be,"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"),c(be,"href","#resources"),c(K,"class","relative group"),c(Oe,"href","https://github.com/huggingface/notebooks/blob/main/examples/image_captioning_pix2struct.ipynb"),c(Oe,"rel","nofollow"),c(Ke,"href","https://huggingface.co/models?search=pix2struct"),c(Ke,"rel","nofollow"),c(ye,"id","transformers.Pix2StructConfig"),c(ye,"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"),c(ye,"href","#transformers.Pix2StructConfig"),c(ee,"class","relative group"),c(Kt,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig"),c(eo,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructForConditionalGeneration"),c(ot,"href","https://huggingface.co/google/pix2struct-base"),c(ot,"rel","nofollow"),c(to,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(oo,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(no,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructConfig"),c(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Pe,"id","transformers.Pix2StructTextConfig"),c(Pe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Pe,"href","#transformers.Pix2StructTextConfig"),c(oe,"class","relative group"),c(ro,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructTextModel"),c(it,"href","https://huggingface.co/google/pix2struct-base"),c(it,"rel","nofollow"),c(so,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(ao,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(ke,"id","transformers.Pix2StructVisionConfig"),c(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"),c(ke,"href","#transformers.Pix2StructVisionConfig"),c(se,"class","relative group"),c(io,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructVisionModel"),c(dt,"href","https://huggingface.co/google/pix2struct-base"),c(dt,"rel","nofollow"),c(lo,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(co,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c($e,"id","transformers.Pix2StructProcessor"),c($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"),c($e,"href","#transformers.Pix2StructProcessor"),c(le,"class","relative group"),c(po,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructProcessor"),c(uo,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructImageProcessor"),c(ho,"href","/docs/transformers/v4.30.0/en/model_doc/t5#transformers.T5TokenizerFast"),c(mo,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructProcessor.decode"),c(fo,"href","/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.batch_decode"),c(Je,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(go,"href","/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.decode"),c(Ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(je,"id","transformers.Pix2StructImageProcessor"),c(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"),c(je,"href","#transformers.Pix2StructImageProcessor"),c(ce,"class","relative group"),c(xt,"href","https://www.tensorflow.org/api_docs/python/tf/image/per_image_standardization"),c(xt,"rel","nofollow"),c(ze,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ee,"id","transformers.Pix2StructTextModel"),c(Ee,"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"),c(Ee,"href","#transformers.Pix2StructTextModel"),c(de,"class","relative group"),c(Pt,"href","https://arxiv.org/abs/2210.03347"),c(Pt,"rel","nofollow"),c(_o,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(St,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(St,"rel","nofollow"),c(vo,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructTextModel"),c(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(We,"id","transformers.Pix2StructVisionModel"),c(We,"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"),c(We,"href","#transformers.Pix2StructVisionModel"),c(ue,"class","relative group"),c(zt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(zt,"rel","nofollow"),c(bo,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructVisionModel"),c(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ve,"id","transformers.Pix2StructForConditionalGeneration"),c(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"),c(Ve,"href","#transformers.Pix2StructForConditionalGeneration"),c(me,"class","relative group"),c(Ft,"href","https://arxiv.org/abs/2210.03347"),c(Ft,"rel","nofollow"),c(xo,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(Zt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Zt,"rel","nofollow"),c(yo,"href","/docs/transformers/v4.30.0/en/model_doc/pix2struct#transformers.Pix2StructForConditionalGeneration"),c(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,h){e(document.head,u),g(t,b,h),g(t,_,h),e(_,m),e(m,v),T(l,v,null),e(_,f),e(_,E),e(E,yr),g(t,wn,h),g(t,O,h),e(O,ge),e(ge,Eo),T(He,Eo,null),e(O,Tr),e(O,Uo),e(Uo,wr),g(t,Pn,h),g(t,_e,h),e(_e,Pr),e(_e,Ye),e(Ye,Mr),e(_e,kr),g(t,Mn,h),g(t,Dt,h),e(Dt,Sr),g(t,kn,h),g(t,Qt,h),e(Qt,Io),e(Io,$r),g(t,Sn,h),g(t,Lt,h),e(Lt,Jr),g(t,$n,h),g(t,Ot,h),e(Ot,Cr),g(t,Jn,h),g(t,ve,h),e(ve,jr),e(ve,Wo),e(Wo,zr),e(ve,Er),g(t,Cn,h),g(t,H,h),e(H,Ur),e(H,De),e(De,Ir),e(H,Wr),e(H,Qe),e(Qe,Fr),e(H,Nr),g(t,jn,h),g(t,K,h),e(K,be),e(be,Fo),T(Le,Fo,null),e(K,Vr),e(K,No),e(No,Zr),g(t,zn,h),g(t,xe,h),e(xe,Vo),e(Vo,Oe),e(Oe,Br),e(xe,Rr),e(xe,Zo),e(Zo,Ke),e(Ke,Gr),g(t,En,h),g(t,ee,h),e(ee,ye),e(ye,Bo),T(et,Bo,null),e(ee,qr),e(ee,Ro),e(Ro,Xr),g(t,Un,h),g(t,C,h),T(tt,C,null),e(C,Ar),e(C,Y),e(Y,Kt),e(Kt,Hr),e(Y,Yr),e(Y,eo),e(eo,Dr),e(Y,Qr),e(Y,ot),e(ot,Lr),e(Y,Or),e(C,Kr),e(C,te),e(te,es),e(te,to),e(to,ts),e(te,os),e(te,oo),e(oo,ns),e(te,rs),e(C,ss),T(Te,C,null),e(C,as),e(C,we),T(nt,we,null),e(we,is),e(we,rt),e(rt,ls),e(rt,no),e(no,cs),e(rt,ds),g(t,In,h),g(t,oe,h),e(oe,Pe),e(Pe,Go),T(st,Go,null),e(oe,ps),e(oe,qo),e(qo,us),g(t,Wn,h),g(t,I,h),T(at,I,null),e(I,hs),e(I,ne),e(ne,ms),e(ne,ro),e(ro,fs),e(ne,gs),e(ne,it),e(it,_s),e(ne,vs),e(I,bs),e(I,re),e(re,xs),e(re,so),e(so,ys),e(re,Ts),e(re,ao),e(ao,ws),e(re,Ps),e(I,Ms),T(Me,I,null),g(t,Fn,h),g(t,se,h),e(se,ke),e(ke,Xo),T(lt,Xo,null),e(se,ks),e(se,Ao),e(Ao,Ss),g(t,Nn,h),g(t,W,h),T(ct,W,null),e(W,$s),e(W,ae),e(ae,Js),e(ae,io),e(io,Cs),e(ae,js),e(ae,dt),e(dt,zs),e(ae,Es),e(W,Us),e(W,ie),e(ie,Is),e(ie,lo),e(lo,Ws),e(ie,Fs),e(ie,co),e(co,Ns),e(ie,Vs),e(W,Zs),T(Se,W,null),g(t,Vn,h),g(t,le,h),e(le,$e),e($e,Ho),T(pt,Ho,null),e(le,Bs),e(le,Yo),e(Yo,Rs),g(t,Zn,h),g(t,j,h),T(ut,j,null),e(j,Gs),e(j,Do),e(Do,qs),e(j,Xs),e(j,U),e(U,po),e(po,As),e(U,Hs),e(U,uo),e(uo,Ys),e(U,Ds),e(U,ho),e(ho,Qs),e(U,Ls),e(U,Qo),e(Qo,Os),e(U,Ks),e(U,mo),e(mo,ea),e(U,ta),e(j,oa),e(j,Je),T(ht,Je,null),e(Je,na),e(Je,mt),e(mt,ra),e(mt,fo),e(fo,sa),e(mt,aa),e(j,ia),e(j,Ce),T(ft,Ce,null),e(Ce,la),e(Ce,gt),e(gt,ca),e(gt,go),e(go,da),e(gt,pa),g(t,Bn,h),g(t,ce,h),e(ce,je),e(je,Lo),T(_t,Lo,null),e(ce,ua),e(ce,Oo),e(Oo,ha),g(t,Rn,h),g(t,G,h),T(vt,G,null),e(G,ma),e(G,Ko),e(Ko,fa),e(G,ga),e(G,ze),T(bt,ze,null),e(ze,_a),e(ze,F),e(F,va),e(F,en),e(en,ba),e(F,xa),e(F,tn),e(tn,ya),e(F,Ta),e(F,on),e(on,wa),e(F,Pa),e(F,xt),e(xt,Ma),e(F,ka),g(t,Gn,h),g(t,de,h),e(de,Ee),e(Ee,nn),T(yt,nn,null),e(de,Sa),e(de,rn),e(rn,$a),g(t,qn,h),g(t,S,h),T(Tt,S,null),e(S,Ja),e(S,sn),e(sn,Ca),e(S,ja),e(S,wt),e(wt,za),e(wt,Pt),e(Pt,Ea),e(wt,Ua),e(S,Ia),e(S,Mt),e(Mt,Wa),e(Mt,_o),e(_o,Fa),e(Mt,Na),e(S,Va),e(S,kt),e(kt,Za),e(kt,St),e(St,Ba),e(kt,Ra),e(S,Ga),e(S,N),T($t,N,null),e(N,qa),e(N,pe),e(pe,Xa),e(pe,vo),e(vo,Aa),e(pe,Ha),e(pe,an),e(an,Ya),e(pe,Da),e(N,Qa),T(Ue,N,null),e(N,La),T(Ie,N,null),g(t,Xn,h),g(t,ue,h),e(ue,We),e(We,ln),T(Jt,ln,null),e(ue,Oa),e(ue,cn),e(cn,Ka),g(t,An,h),g(t,q,h),T(Ct,q,null),e(q,ei),e(q,jt),e(jt,ti),e(jt,zt),e(zt,oi),e(jt,ni),e(q,ri),e(q,V),T(Et,V,null),e(V,si),e(V,he),e(he,ai),e(he,bo),e(bo,ii),e(he,li),e(he,dn),e(dn,ci),e(he,di),e(V,pi),T(Fe,V,null),e(V,ui),T(Ne,V,null),g(t,Hn,h),g(t,me,h),e(me,Ve),e(Ve,pn),T(Ut,pn,null),e(me,hi),e(me,un),e(un,mi),g(t,Yn,h),g(t,$,h),T(It,$,null),e($,fi),e($,hn),e(hn,gi),e($,_i),e($,Wt),e(Wt,vi),e(Wt,Ft),e(Ft,bi),e(Wt,xi),e($,yi),e($,Nt),e(Nt,Ti),e(Nt,xo),e(xo,wi),e(Nt,Pi),e($,Mi),e($,Vt),e(Vt,ki),e(Vt,Zt),e(Zt,Si),e(Vt,$i),e($,Ji),e($,J),T(Bt,J,null),e(J,Ci),e(J,fe),e(fe,ji),e(fe,yo),e(yo,zi),e(fe,Ei),e(fe,mn),e(mn,Ui),e(fe,Ii),e(J,Wi),T(Ze,J,null),e(J,Fi),e(J,fn),e(fn,Ni),e(J,Vi),T(Be,J,null),e(J,Zi),T(Re,J,null),Dn=!0},p(t,[h]){const Rt={};h&2&&(Rt.$$scope={dirty:h,ctx:t}),Te.$set(Rt);const gn={};h&2&&(gn.$$scope={dirty:h,ctx:t}),Me.$set(gn);const _n={};h&2&&(_n.$$scope={dirty:h,ctx:t}),Se.$set(_n);const vn={};h&2&&(vn.$$scope={dirty:h,ctx:t}),Ue.$set(vn);const Gt={};h&2&&(Gt.$$scope={dirty:h,ctx:t}),Ie.$set(Gt);const bn={};h&2&&(bn.$$scope={dirty:h,ctx:t}),Fe.$set(bn);const xn={};h&2&&(xn.$$scope={dirty:h,ctx:t}),Ne.$set(xn);const yn={};h&2&&(yn.$$scope={dirty:h,ctx:t}),Ze.$set(yn);const qt={};h&2&&(qt.$$scope={dirty:h,ctx:t}),Be.$set(qt);const Tn={};h&2&&(Tn.$$scope={dirty:h,ctx:t}),Re.$set(Tn)},i(t){Dn||(w(l.$$.fragment,t),w(He.$$.fragment,t),w(Le.$$.fragment,t),w(et.$$.fragment,t),w(tt.$$.fragment,t),w(Te.$$.fragment,t),w(nt.$$.fragment,t),w(st.$$.fragment,t),w(at.$$.fragment,t),w(Me.$$.fragment,t),w(lt.$$.fragment,t),w(ct.$$.fragment,t),w(Se.$$.fragment,t),w(pt.$$.fragment,t),w(ut.$$.fragment,t),w(ht.$$.fragment,t),w(ft.$$.fragment,t),w(_t.$$.fragment,t),w(vt.$$.fragment,t),w(bt.$$.fragment,t),w(yt.$$.fragment,t),w(Tt.$$.fragment,t),w($t.$$.fragment,t),w(Ue.$$.fragment,t),w(Ie.$$.fragment,t),w(Jt.$$.fragment,t),w(Ct.$$.fragment,t),w(Et.$$.fragment,t),w(Fe.$$.fragment,t),w(Ne.$$.fragment,t),w(Ut.$$.fragment,t),w(It.$$.fragment,t),w(Bt.$$.fragment,t),w(Ze.$$.fragment,t),w(Be.$$.fragment,t),w(Re.$$.fragment,t),Dn=!0)},o(t){P(l.$$.fragment,t),P(He.$$.fragment,t),P(Le.$$.fragment,t),P(et.$$.fragment,t),P(tt.$$.fragment,t),P(Te.$$.fragment,t),P(nt.$$.fragment,t),P(st.$$.fragment,t),P(at.$$.fragment,t),P(Me.$$.fragment,t),P(lt.$$.fragment,t),P(ct.$$.fragment,t),P(Se.$$.fragment,t),P(pt.$$.fragment,t),P(ut.$$.fragment,t),P(ht.$$.fragment,t),P(ft.$$.fragment,t),P(_t.$$.fragment,t),P(vt.$$.fragment,t),P(bt.$$.fragment,t),P(yt.$$.fragment,t),P(Tt.$$.fragment,t),P($t.$$.fragment,t),P(Ue.$$.fragment,t),P(Ie.$$.fragment,t),P(Jt.$$.fragment,t),P(Ct.$$.fragment,t),P(Et.$$.fragment,t),P(Fe.$$.fragment,t),P(Ne.$$.fragment,t),P(Ut.$$.fragment,t),P(It.$$.fragment,t),P(Bt.$$.fragment,t),P(Ze.$$.fragment,t),P(Be.$$.fragment,t),P(Re.$$.fragment,t),Dn=!1},d(t){o(u),t&&o(b),t&&o(_),M(l),t&&o(wn),t&&o(O),M(He),t&&o(Pn),t&&o(_e),t&&o(Mn),t&&o(Dt),t&&o(kn),t&&o(Qt),t&&o(Sn),t&&o(Lt),t&&o($n),t&&o(Ot),t&&o(Jn),t&&o(ve),t&&o(Cn),t&&o(H),t&&o(jn),t&&o(K),M(Le),t&&o(zn),t&&o(xe),t&&o(En),t&&o(ee),M(et),t&&o(Un),t&&o(C),M(tt),M(Te),M(nt),t&&o(In),t&&o(oe),M(st),t&&o(Wn),t&&o(I),M(at),M(Me),t&&o(Fn),t&&o(se),M(lt),t&&o(Nn),t&&o(W),M(ct),M(Se),t&&o(Vn),t&&o(le),M(pt),t&&o(Zn),t&&o(j),M(ut),M(ht),M(ft),t&&o(Bn),t&&o(ce),M(_t),t&&o(Rn),t&&o(G),M(vt),M(bt),t&&o(Gn),t&&o(de),M(yt),t&&o(qn),t&&o(S),M(Tt),M($t),M(Ue),M(Ie),t&&o(Xn),t&&o(ue),M(Jt),t&&o(An),t&&o(q),M(Ct),M(Et),M(Fe),M(Ne),t&&o(Hn),t&&o(me),M(Ut),t&&o(Yn),t&&o($),M(It),M(Bt),M(Ze),M(Be),M(Re)}}}const zc={local:"pix2struct",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.Pix2StructConfig",title:"Pix2StructConfig"},{local:"transformers.Pix2StructTextConfig",title:"Pix2StructTextConfig"},{local:"transformers.Pix2StructVisionConfig",title:"Pix2StructVisionConfig"},{local:"transformers.Pix2StructProcessor",title:"Pix2StructProcessor"},{local:"transformers.Pix2StructImageProcessor",title:"Pix2StructImageProcessor"},{local:"transformers.Pix2StructTextModel",title:"Pix2StructTextModel"},{local:"transformers.Pix2StructVisionModel",title:"Pix2StructVisionModel"},{local:"transformers.Pix2StructForConditionalGeneration",title:"Pix2StructForConditionalGeneration"}],title:"Pix2Struct"};function Ec(k){return xc(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zc extends gc{constructor(u){super();_c(this,u,Ec,jc,vc,{})}}export{Zc as default,zc as metadata};
