import{S as Mb,i as wb,s as Lb,e as a,k as d,w as g,t as n,M as kb,c as r,d as o,m as p,a as l,x as y,h as s,b as i,G as e,g as u,y as _,q as v,o as b,B as M,v as Tb,L as Ds}from"../../chunks/vendor-hf-doc-builder.js";import{T as Pi}from"../../chunks/Tip-hf-doc-builder.js";import{D as F}from"../../chunks/Docstring-hf-doc-builder.js";import{C as V}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Y}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ps}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Bg}from"../../chunks/PipelineTag-hf-doc-builder.js";function xb(I){let h,k,f,w,T;return w=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJDb25maWclMkMlMjBMYXlvdXRMTXYyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwTGF5b3V0TE12MiUyMG1pY3Jvc29mdCUyRmxheW91dGxtdjItYmFzZS11bmNhc2VkJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMExheW91dExNdjJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwbWljcm9zb2Z0JTJGbGF5b3V0bG12Mi1iYXNlLXVuY2FzZWQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMExheW91dExNdjJNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Config, LayoutLMv2Model

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a LayoutLMv2 microsoft/layoutlmv2-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = LayoutLMv2Config()

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

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2Model.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/fixtures_docvqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_path = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;file&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(image_path).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states.shape
torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">342</span>, <span class="hljs-number">768</span>])`}}),{c(){h=a("p"),k=n("Examples:"),f=d(),g(w.$$.fragment)},l(m){h=r(m,"P",{});var L=l(h);k=s(L,"Examples:"),L.forEach(o),f=p(m),y(w.$$.fragment,m)},m(m,L){u(m,h,L),e(h,k),u(m,f,L),_(w,m,L),T=!0},p:Ds,i(m){T||(v(w.$$.fragment,m),T=!0)},o(m){b(w.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),M(w,m)}}}function Ub(I){let h,k,f,w,T;return{c(){h=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),w=n("Module"),T=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(m){h=r(m,"P",{});var L=l(h);k=s(L,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(L,"CODE",{});var R=l(f);w=s(R,"Module"),R.forEach(o),T=s(L,`
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.forEach(o)},m(m,L){u(m,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(m){m&&o(h)}}}function Eb(I){let h,k,f,w,T;return w=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBMYXlvdXRMTXYyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUyQyUyMHNldF9zZWVkJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFzZXRfc2VlZCg4OCklMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMnJ2bF9jZGlwJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUpJTBBZGF0YSUyMCUzRCUyMG5leHQoaXRlcihkYXRhc2V0KSklMEFpbWFnZSUyMCUzRCUyMGRhdGElNUIlMjJpbWFnZSUyMiU1RC5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMExheW91dExNdjJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0RkYXRhc2V0LmluZm8uZmVhdHVyZXMlNUIlMjJsYWJlbCUyMiU1RC5udW1fY2xhc3NlcyUwQSklMEElMEFlbmNvZGluZyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBc2VxdWVuY2VfbGFiZWwlMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCZGF0YSU1QiUyMmxhYmVsJTIyJTVEJTVEKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmVuY29kaW5nJTJDJTIwbGFiZWxzJTNEc2VxdWVuY2VfbGFiZWwpJTBBJTBBbG9zcyUyQyUyMGxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9zcyUyQyUyMG91dHB1dHMubG9naXRzJTBBcHJlZGljdGVkX2lkeCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoZGltJTNELTEpLml0ZW0oKSUwQXByZWRpY3RlZF9hbnN3ZXIlMjAlM0QlMjBkYXRhc2V0LmluZm8uZmVhdHVyZXMlNUIlMjJsYWJlbCUyMiU1RC5uYW1lcyU1QjQlNUQlMEFwcmVkaWN0ZWRfaWR4JTJDJTIwcHJlZGljdGVkX2Fuc3dlcg==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2ForSequenceClassification, set_seed
<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> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;rvl_cdip&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>data = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset))
<span class="hljs-meta">&gt;&gt;&gt; </span>image = data[<span class="hljs-string">&quot;image&quot;</span>].convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2ForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, num_labels=dataset.info.features[<span class="hljs-string">&quot;label&quot;</span>].num_classes
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence_label = torch.tensor([data[<span class="hljs-string">&quot;label&quot;</span>]])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, labels=sequence_label)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss, logits = outputs.loss, outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_idx = logits.argmax(dim=-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer = dataset.info.features[<span class="hljs-string">&quot;label&quot;</span>].names[<span class="hljs-number">4</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_idx, predicted_answer
(<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;advertisement&#x27;</span>)`}}),{c(){h=a("p"),k=n("Example:"),f=d(),g(w.$$.fragment)},l(m){h=r(m,"P",{});var L=l(h);k=s(L,"Example:"),L.forEach(o),f=p(m),y(w.$$.fragment,m)},m(m,L){u(m,h,L),e(h,k),u(m,f,L),_(w,m,L),T=!0},p:Ds,i(m){T||(v(w.$$.fragment,m),T=!0)},o(m){b(w.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),M(w,m)}}}function zb(I){let h,k,f,w,T;return{c(){h=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),w=n("Module"),T=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(m){h=r(m,"P",{});var L=l(h);k=s(L,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(L,"CODE",{});var R=l(f);w=s(R,"Module"),R.forEach(o),T=s(L,`
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.forEach(o)},m(m,L){u(m,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(m){m&&o(h)}}}function Ib(I){let h,k,f,w,T;return w=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBMYXlvdXRMTXYyRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUyQyUyMHNldF9zZWVkJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBc2V0X3NlZWQoODgpJTBBJTBBZGF0YXNldHMlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIybmllbHNyJTJGZnVuc2QlMjIlMkMlMjBzcGxpdCUzRCUyMnRlc3QlMjIpJTBBbGFiZWxzJTIwJTNEJTIwZGF0YXNldHMuZmVhdHVyZXMlNUIlMjJuZXJfdGFncyUyMiU1RC5mZWF0dXJlLm5hbWVzJTBBaWQybGFiZWwlMjAlM0QlMjAlN0J2JTNBJTIwayUyMGZvciUyMHYlMkMlMjBrJTIwaW4lMjBlbnVtZXJhdGUobGFiZWxzKSU3RCUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmxheW91dGxtdjItYmFzZS11bmNhc2VkJTIyJTJDJTIwcmV2aXNpb24lM0QlMjJub19vY3IlMjIpJTBBbW9kZWwlMjAlM0QlMjBMYXlvdXRMTXYyRm9yVG9rZW5DbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybWljcm9zb2Z0JTJGbGF5b3V0bG12Mi1iYXNlLXVuY2FzZWQlMjIlMkMlMjBudW1fbGFiZWxzJTNEbGVuKGxhYmVscyklMEEpJTBBJTBBZGF0YSUyMCUzRCUyMGRhdGFzZXRzJTVCMCU1RCUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihkYXRhJTVCJTIyaW1hZ2VfcGF0aCUyMiU1RCkuY29udmVydCglMjJSR0IlMjIpJTBBd29yZHMlMjAlM0QlMjBkYXRhJTVCJTIyd29yZHMlMjIlNUQlMEFib3hlcyUyMCUzRCUyMGRhdGElNUIlMjJiYm94ZXMlMjIlNUQlMjAlMjAlMjMlMjBtYWtlJTIwc3VyZSUyMHRvJTIwbm9ybWFsaXplJTIweW91ciUyMGJvdW5kaW5nJTIwYm94ZXMlMEF3b3JkX2xhYmVscyUyMCUzRCUyMGRhdGElNUIlMjJuZXJfdGFncyUyMiU1RCUwQWVuY29kaW5nJTIwJTNEJTIwcHJvY2Vzc29yKCUwQSUyMCUyMCUyMCUyMGltYWdlJTJDJTBBJTIwJTIwJTIwJTIwd29yZHMlMkMlMEElMjAlMjAlMjAlMjBib3hlcyUzRGJveGVzJTJDJTBBJTIwJTIwJTIwJTIwd29yZF9sYWJlbHMlM0R3b3JkX2xhYmVscyUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTBBJTIwJTIwJTIwJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmVuY29kaW5nKSUwQWxvZ2l0cyUyQyUyMGxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUyQyUyMG91dHB1dHMubG9zcyUwQSUwQXByZWRpY3RlZF90b2tlbl9jbGFzc19pZHMlMjAlM0QlMjBsb2dpdHMuYXJnbWF4KC0xKSUwQXByZWRpY3RlZF90b2tlbnNfY2xhc3NlcyUyMCUzRCUyMCU1QmlkMmxhYmVsJTVCdC5pdGVtKCklNUQlMjBmb3IlMjB0JTIwaW4lMjBwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTVCMCU1RCU1RCUwQXByZWRpY3RlZF90b2tlbnNfY2xhc3NlcyU1QiUzQTUlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2ForTokenClassification, set_seed
<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> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>datasets = load_dataset(<span class="hljs-string">&quot;nielsr/funsd&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = datasets.features[<span class="hljs-string">&quot;ner_tags&quot;</span>].feature.names
<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = {v: k <span class="hljs-keyword">for</span> v, k <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(labels)}

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2ForTokenClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, num_labels=<span class="hljs-built_in">len</span>(labels)
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>data = datasets[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(data[<span class="hljs-string">&quot;image_path&quot;</span>]).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>words = data[<span class="hljs-string">&quot;words&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>boxes = data[<span class="hljs-string">&quot;bboxes&quot;</span>]  <span class="hljs-comment"># make sure to normalize your bounding boxes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>word_labels = data[<span class="hljs-string">&quot;ner_tags&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(
<span class="hljs-meta">... </span>    image,
<span class="hljs-meta">... </span>    words,
<span class="hljs-meta">... </span>    boxes=boxes,
<span class="hljs-meta">... </span>    word_labels=word_labels,
<span class="hljs-meta">... </span>    padding=<span class="hljs-string">&quot;max_length&quot;</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits, loss = outputs.logits, outputs.loss

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class_ids = logits.argmax(-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes = [id2label[t.item()] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predicted_token_class_ids[<span class="hljs-number">0</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes[:<span class="hljs-number">5</span>]
[<span class="hljs-string">&#x27;B-ANSWER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>, <span class="hljs-string">&#x27;B-HEADER&#x27;</span>]`}}),{c(){h=a("p"),k=n("Example:"),f=d(),g(w.$$.fragment)},l(m){h=r(m,"P",{});var L=l(h);k=s(L,"Example:"),L.forEach(o),f=p(m),y(w.$$.fragment,m)},m(m,L){u(m,h,L),e(h,k),u(m,f,L),_(w,m,L),T=!0},p:Ds,i(m){T||(v(w.$$.fragment,m),T=!0)},o(m){b(w.$$.fragment,m),T=!1},d(m){m&&o(h),m&&o(f),M(w,m)}}}function Cb(I){let h,k,f,w,T;return{c(){h=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),w=n("Module"),T=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(m){h=r(m,"P",{});var L=l(h);k=s(L,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(L,"CODE",{});var R=l(f);w=s(R,"Module"),R.forEach(o),T=s(L,`
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.forEach(o)},m(m,L){u(m,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(m){m&&o(h)}}}function $b(I){let h,k;return h=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBMYXlvdXRMTXYyRm9yUXVlc3Rpb25BbnN3ZXJpbmclMkMlMjBzZXRfc2VlZCUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBc2V0X3NlZWQoODgpJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGbGF5b3V0bG12Mi1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBMYXlvdXRMTXYyRm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmxheW91dGxtdjItYmFzZS11bmNhc2VkJTIyKSUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRmZpeHR1cmVzX2RvY3ZxYSUyMiklMEFpbWFnZV9wYXRoJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIwJTVEJTVCJTIyZmlsZSUyMiU1RCUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihpbWFnZV9wYXRoKS5jb252ZXJ0KCUyMlJHQiUyMiklMEFxdWVzdGlvbiUyMCUzRCUyMCUyMldoZW4lMjBpcyUyMGNvZmZlZSUyMGJyZWFrJTNGJTIyJTBBZW5jb2RpbmclMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjBxdWVzdGlvbiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqZW5jb2RpbmcpJTBBcHJlZGljdGVkX3N0YXJ0X2lkeCUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzLmFyZ21heCgtMSkuaXRlbSgpJTBBcHJlZGljdGVkX2VuZF9pZHglMjAlM0QlMjBvdXRwdXRzLmVuZF9sb2dpdHMuYXJnbWF4KC0xKS5pdGVtKCklMEFwcmVkaWN0ZWRfc3RhcnRfaWR4JTJDJTIwcHJlZGljdGVkX2VuZF9pZHglMEElMEFwcmVkaWN0ZWRfYW5zd2VyX3Rva2VucyUyMCUzRCUyMGVuY29kaW5nLmlucHV0X2lkcy5zcXVlZXplKCklNUJwcmVkaWN0ZWRfc3RhcnRfaWR4JTIwJTNBJTIwcHJlZGljdGVkX2VuZF9pZHglMjAlMkIlMjAxJTVEJTBBcHJlZGljdGVkX2Fuc3dlciUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIuZGVjb2RlKHByZWRpY3RlZF9hbnN3ZXJfdG9rZW5zKSUwQXByZWRpY3RlZF9hbnN3ZXIlMjAlMjAlMjMlMjByZXN1bHRzJTIwYXJlJTIwbm90JTIwdmVyeSUyMGdvb2QlMjB3aXRob3V0JTIwZnVydGhlciUyMGZpbmUtdHVuaW5n",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, LayoutLMv2ForQuestionAnswering, set_seed
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<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> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>set_seed(<span class="hljs-number">88</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMv2ForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/fixtures_docvqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_path = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;file&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(image_path).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;When is coffee break?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = processor(image, question, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_start_idx = outputs.start_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_end_idx = outputs.end_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_start_idx, predicted_end_idx
(<span class="hljs-number">154</span>, <span class="hljs-number">287</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_tokens = encoding.input_ids.squeeze()[predicted_start_idx : predicted_end_idx + <span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer = processor.tokenizer.decode(predicted_answer_tokens)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer  <span class="hljs-comment"># results are not very good without further fine-tuning</span>
<span class="hljs-string">&#x27;council mem - bers conducted by trrf treasurer philip g. kuehn to get answers which the public ...</span>`}}),{c(){g(h.$$.fragment)},l(f){y(h.$$.fragment,f)},m(f,w){_(h,f,w),k=!0},p:Ds,i(f){k||(v(h.$$.fragment,f),k=!0)},o(f){b(h.$$.fragment,f),k=!1},d(f){M(h,f)}}}function Fb(I){let h,k;return h=new V({props:{code:"dGFyZ2V0X3N0YXJ0X2luZGV4JTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QjclNUQpJTBBdGFyZ2V0X2VuZF9pbmRleCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxNCU1RCklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKiplbmNvZGluZyUyQyUyMHN0YXJ0X3Bvc2l0aW9ucyUzRHRhcmdldF9zdGFydF9pbmRleCUyQyUyMGVuZF9wb3NpdGlvbnMlM0R0YXJnZXRfZW5kX2luZGV4KSUwQXByZWRpY3RlZF9hbnN3ZXJfc3Bhbl9zdGFydCUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzLmFyZ21heCgtMSkuaXRlbSgpJTBBcHJlZGljdGVkX2Fuc3dlcl9zcGFuX2VuZCUyMCUzRCUyMG91dHB1dHMuZW5kX2xvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByZWRpY3RlZF9hbnN3ZXJfc3Bhbl9zdGFydCUyQyUyMHByZWRpY3RlZF9hbnN3ZXJfc3Bhbl9lbmQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>target_start_index = torch.tensor([<span class="hljs-number">7</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>target_end_index = torch.tensor([<span class="hljs-number">14</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, start_positions=target_start_index, end_positions=target_end_index)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_span_start = outputs.start_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_span_end = outputs.end_logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_answer_span_start, predicted_answer_span_end
(<span class="hljs-number">154</span>, <span class="hljs-number">287</span>)`}}),{c(){g(h.$$.fragment)},l(f){y(h.$$.fragment,f)},m(f,w){_(h,f,w),k=!0},p:Ds,i(f){k||(v(h.$$.fragment,f),k=!0)},o(f){b(h.$$.fragment,f),k=!1},d(f){M(h,f)}}}function Zb(I){let h,k,f,w,T,m,L,R,Di,Or,je,Qe,Qs,Ft,Qi,Ys,Yi,Hr,me,Oi,Zt,Hi,Ki,Tn,ec,tc,Kr,he,O,oc,Wt,nc,sc,Rt,ac,rc,Nt,lc,ic,qt,cc,dc,pc,Bt,uc,At,mc,hc,fc,Xt,gc,Vt,yc,_c,el,xn,vc,tl,jn,Os,bc,ol,se,Mc,Hs,wc,Lc,Ks,kc,Tc,ea,xc,jc,nl,Gt,sl,Jn,Jc,al,Un,Uc,rl,G,ta,Ec,zc,St,Ic,Pt,Cc,$c,Fc,Dt,Zc,Qt,Wc,Rc,Nc,Je,qc,Yt,Bc,Ac,Ot,Xc,Vc,Gc,x,Sc,oa,Pc,Dc,En,Qc,Yc,na,Oc,Hc,sa,Kc,ed,aa,td,od,ra,nd,sd,la,ad,rd,ia,ld,id,ca,cd,dd,zn,pd,ud,Ht,md,hd,Kt,fd,gd,ll,eo,il,fe,yd,da,_d,vd,pa,bd,Md,cl,to,dl,Ye,wd,In,Ld,kd,pl,ge,Z,Td,Cn,xd,jd,ua,Jd,Ud,ma,Ed,zd,$n,Id,Cd,ha,$d,Fd,fa,Zd,Wd,ga,Rd,Nd,qd,oo,Bd,Fn,Ad,Xd,Vd,no,Gd,ya,Sd,Pd,ul,Oe,Dd,Zn,Qd,Yd,ml,Ue,He,_a,so,Od,va,Hd,hl,Wn,Kd,fl,ao,gl,Ke,ro,ep,lo,tp,op,np,Rn,sp,Nn,ap,yl,io,_l,ye,co,rp,po,lp,ip,cp,qn,dp,Bn,pp,up,An,mp,Xn,hp,vl,uo,bl,_e,mo,fp,ho,gp,yp,_p,fo,vp,go,bp,Mp,wp,Vn,Lp,Gn,kp,Ml,Ee,et,ba,yo,Tp,Ma,xp,wl,S,jp,Sn,Jp,Up,Pn,Ep,zp,Dn,Ip,Cp,Qn,$p,Fp,Ll,_o,kl,J,Zp,Yn,Wp,Rp,On,Np,qp,wa,Bp,Ap,Hn,Xp,Vp,Kn,Gp,Sp,La,Pp,Dp,ka,Qp,Yp,Ta,Op,Hp,xa,Kp,eu,ja,tu,ou,Tl,A,es,nu,su,vo,au,ru,ts,lu,iu,Ja,cu,du,Ua,pu,uu,xl,os,mu,jl,ns,Ea,hu,Jl,ss,fu,Ul,bo,El,as,za,gu,zl,ve,yu,Ia,_u,vu,Ca,bu,Mu,Il,Mo,Cl,rs,$a,wu,$l,P,Lu,Fa,ku,Tu,Za,xu,ju,Wa,Ju,Uu,Ra,Eu,zu,Fl,wo,Zl,ls,Na,Iu,Wl,is,Cu,Rl,Lo,Nl,cs,qa,$u,ql,ds,Fu,Bl,ko,Al,ze,tt,Ba,To,Zu,Aa,Wu,Xl,H,xo,Ru,Ie,Nu,ps,qu,Bu,jo,Au,Xu,Vu,Ce,Gu,us,Su,Pu,ms,Du,Qu,Yu,ot,Vl,$e,nt,Xa,Jo,Ou,Va,Hu,Gl,Fe,Uo,Ku,st,Eo,em,Ga,tm,Sl,Ze,at,Sa,zo,om,Pa,nm,Pl,ce,Io,sm,Da,am,rm,rt,Co,lm,Qa,im,Dl,We,lt,Ya,$o,cm,Oa,dm,Ql,N,Fo,pm,q,um,hs,mm,hm,Ha,fm,gm,Ka,ym,_m,er,vm,bm,tr,Mm,wm,or,Lm,km,Tm,Zo,xm,fs,jm,Jm,Um,gs,ys,Em,zm,Im,it,Wo,Cm,nr,$m,Fm,_s,Ro,Yl,Re,ct,sr,No,Zm,ar,Wm,Ol,K,qo,Rm,Bo,Nm,rr,qm,Bm,Am,Ao,Xm,vs,Vm,Gm,Sm,dt,Xo,Pm,lr,Dm,Hl,Ne,pt,ir,Vo,Qm,cr,Ym,Kl,X,Go,Om,dr,Hm,Km,bs,Ms,eh,th,oh,z,nh,ws,sh,ah,Ls,rh,lh,ks,ih,ch,pr,dh,ph,ur,uh,mh,mr,hh,fh,hr,gh,yh,fr,_h,vh,gr,bh,Mh,wh,be,So,Lh,j,kh,yr,Th,xh,Po,_r,jh,Jh,Uh,Ts,Eh,zh,vr,Ih,Ch,br,$h,Fh,Do,Mr,Zh,Wh,Rh,wr,Nh,qh,xs,Bh,Ah,Lr,Xh,Vh,kr,Gh,Sh,Tr,Ph,Dh,xr,Qh,Yh,Oh,jr,Hh,ei,qe,ut,Jr,Qo,Kh,Ur,ef,ti,de,Yo,tf,Oo,of,Ho,nf,sf,af,ae,Ko,rf,Be,lf,js,cf,df,Er,pf,uf,mf,mt,hf,ht,oi,Ae,ft,zr,en,ff,Ir,gf,ni,ee,tn,yf,on,_f,nn,vf,bf,Mf,sn,wf,an,Lf,kf,Tf,re,rn,xf,Xe,jf,Js,Jf,Uf,Cr,Ef,zf,If,gt,Cf,yt,si,Ve,_t,$r,ln,$f,Fr,Ff,ai,te,cn,Zf,oe,Wf,dn,Rf,Nf,pn,qf,Bf,un,Af,Xf,mn,Vf,Gf,Sf,hn,Pf,fn,Df,Qf,Yf,le,gn,Of,Ge,Hf,Us,Kf,eg,Zr,tg,og,ng,vt,sg,bt,ri,Se,Mt,Wr,yn,ag,Rr,rg,li,ne,_n,lg,pe,ig,vn,cg,dg,Nr,pg,ug,qr,mg,hg,fg,bn,gg,Mn,yg,_g,vg,W,wn,bg,Pe,Mg,Es,wg,Lg,Br,kg,Tg,xg,wt,jg,Ar,Jg,Ug,Xr,Eg,zg,Lt,Ig,kt,ii;return m=new Y({}),Ft=new Y({}),Gt=new V({props:{code:"cHl0aG9uJTIwLW0lMjBwaXAlMjBpbnN0YWxsJTIwJ2dpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmZhY2Vib29rcmVzZWFyY2glMkZkZXRlY3Ryb24yLmdpdCclMEFweXRob24lMjAtbSUyMHBpcCUyMGluc3RhbGwlMjB0b3JjaHZpc2lvbiUyMHRlc3NlcmFjdA==",highlighted:`<span class="hljs-keyword">python</span> -m pip install <span class="hljs-string">&#x27;git+https://github.com/facebookresearch/detectron2.git&#x27;</span>
<span class="hljs-keyword">python</span> -m pip install torchvision tesseract`}}),eo=new V({props:{code:"ZGVmJTIwbm9ybWFsaXplX2Jib3goYmJveCUyQyUyMHdpZHRoJTJDJTIwaGVpZ2h0KSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGludCgxMDAwJTIwKiUyMChiYm94JTVCMCU1RCUyMCUyRiUyMHdpZHRoKSklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnQoMTAwMCUyMColMjAoYmJveCU1QjElNUQlMjAlMkYlMjBoZWlnaHQpKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGludCgxMDAwJTIwKiUyMChiYm94JTVCMiU1RCUyMCUyRiUyMHdpZHRoKSklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnQoMTAwMCUyMColMjAoYmJveCU1QjMlNUQlMjAlMkYlMjBoZWlnaHQpKSUyQyUwQSUyMCUyMCUyMCUyMCU1RA==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">normalize_bbox</span>(<span class="hljs-params">bbox, width, height</span>):
    <span class="hljs-keyword">return</span> [
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">0</span>] / width)),
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">1</span>] / height)),
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">2</span>] / width)),
        <span class="hljs-built_in">int</span>(<span class="hljs-number">1000</span> * (bbox[<span class="hljs-number">3</span>] / height)),
    ]`}}),to=new V({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKCUwQSUyMCUyMCUyMCUyMCUyMm5hbWVfb2ZfeW91cl9kb2N1bWVudCUyMC0lMjBjYW4lMjBiZSUyMGElMjBwbmclMkMlMjBqcGclMkMlMjBldGMuJTIwb2YlMjB5b3VyJTIwZG9jdW1lbnRzJTIwKFBERnMlMjBtdXN0JTIwYmUlMjBjb252ZXJ0ZWQlMjB0byUyMGltYWdlcykuJTIyJTBBKSUwQSUwQXdpZHRoJTJDJTIwaGVpZ2h0JTIwJTNEJTIwaW1hZ2Uuc2l6ZQ==",highlighted:`<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

image = Image.<span class="hljs-built_in">open</span>(
    <span class="hljs-string">&quot;name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
)

width, height = image.size`}}),so=new Y({}),ao=new Bg({props:{pipeline:"text-classification"}}),io=new Bg({props:{pipeline:"question-answering"}}),uo=new Bg({props:{pipeline:"token-classification"}}),yo=new Y({}),_o=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJGZWF0dXJlRXh0cmFjdG9yJTJDJTIwTGF5b3V0TE12MlRva2VuaXplckZhc3QlMkMlMjBMYXlvdXRMTXYyUHJvY2Vzc29yJTBBJTBBZmVhdHVyZV9leHRyYWN0b3IlMjAlM0QlMjBMYXlvdXRMTXYyRmVhdHVyZUV4dHJhY3RvcigpJTIwJTIwJTIzJTIwYXBwbHlfb2NyJTIwaXMlMjBzZXQlMjB0byUyMFRydWUlMjBieSUyMGRlZmF1bHQlMEF0b2tlbml6ZXIlMjAlM0QlMjBMYXlvdXRMTXYyVG9rZW5pemVyRmFzdC5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGbGF5b3V0bG12Mi1iYXNlLXVuY2FzZWQlMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwTGF5b3V0TE12MlByb2Nlc3NvcihmZWF0dXJlX2V4dHJhY3RvciUyQyUyMHRva2VuaXplcik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2FeatureExtractor, LayoutLMv2TokenizerFast, LayoutLMv2Processor

feature_extractor = LayoutLMv2FeatureExtractor()  <span class="hljs-comment"># apply_ocr is set to True by default</span>
tokenizer = LayoutLMv2TokenizerFast.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)
processor = LayoutLMv2Processor(feature_extractor, tokenizer)`}}),bo=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJQcm9jZXNzb3IlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBMYXlvdXRMTXYyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiklMEElMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4oJTBBJTIwJTIwJTIwJTIwJTIybmFtZV9vZl95b3VyX2RvY3VtZW50JTIwLSUyMGNhbiUyMGJlJTIwYSUyMHBuZyUyQyUyMGpwZyUyQyUyMGV0Yy4lMjBvZiUyMHlvdXIlMjBkb2N1bWVudHMlMjAoUERGcyUyMG11c3QlMjBiZSUyMGNvbnZlcnRlZCUyMHRvJTIwaW1hZ2VzKS4lMjIlMEEpLmNvbnZlcnQoJTIyUkdCJTIyKSUwQWVuY29kaW5nJTIwJTNEJTIwcHJvY2Vzc29yKCUwQSUyMCUyMCUyMCUyMGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUwQSklMjAlMjAlMjMlMjB5b3UlMjBjYW4lMjBhbHNvJTIwYWRkJTIwYWxsJTIwdG9rZW5pemVyJTIwcGFyYW1ldGVycyUyMGhlcmUlMjBzdWNoJTIwYXMlMjBwYWRkaW5nJTJDJTIwdHJ1bmNhdGlvbiUwQXByaW50KGVuY29kaW5nLmtleXMoKSklMEElMjMlMjBkaWN0X2tleXMoJTVCJ2lucHV0X2lkcyclMkMlMjAndG9rZW5fdHlwZV9pZHMnJTJDJTIwJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdiYm94JyUyQyUyMCdpbWFnZSclNUQp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(
    <span class="hljs-string">&quot;name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
encoding = processor(
    image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
)  <span class="hljs-comment"># you can also add all tokenizer parameters here such as padding, truncation</span>
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),Mo=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJQcm9jZXNzb3IlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBMYXlvdXRMTXYyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiUyQyUyMHJldmlzaW9uJTNEJTIybm9fb2NyJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbiglMEElMjAlMjAlMjAlMjAlMjJuYW1lX29mX3lvdXJfZG9jdW1lbnQlMjAtJTIwY2FuJTIwYmUlMjBhJTIwcG5nJTJDJTIwanBnJTJDJTIwZXRjLiUyMG9mJTIweW91ciUyMGRvY3VtZW50cyUyMChQREZzJTIwbXVzdCUyMGJlJTIwY29udmVydGVkJTIwdG8lMjBpbWFnZXMpLiUyMiUwQSkuY29udmVydCglMjJSR0IlMjIpJTBBd29yZHMlMjAlM0QlMjAlNUIlMjJoZWxsbyUyMiUyQyUyMCUyMndvcmxkJTIyJTVEJTBBYm94ZXMlMjAlM0QlMjAlNUIlNUIxJTJDJTIwMiUyQyUyMDMlMkMlMjA0JTVEJTJDJTIwJTVCNSUyQyUyMDYlMkMlMjA3JTJDJTIwOCU1RCU1RCUyMCUyMCUyMyUyMG1ha2UlMjBzdXJlJTIwdG8lMjBub3JtYWxpemUlMjB5b3VyJTIwYm91bmRpbmclMjBib3hlcyUwQWVuY29kaW5nJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlJTJDJTIwd29yZHMlMkMlMjBib3hlcyUzRGJveGVzJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFwcmludChlbmNvZGluZy5rZXlzKCkpJTBBJTIzJTIwZGljdF9rZXlzKCU1QidpbnB1dF9pZHMnJTJDJTIwJ3Rva2VuX3R5cGVfaWRzJyUyQyUyMCdhdHRlbnRpb25fbWFzayclMkMlMjAnYmJveCclMkMlMjAnaW1hZ2UnJTVEKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(
    <span class="hljs-string">&quot;name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
boxes = [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>], [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>]]  <span class="hljs-comment"># make sure to normalize your bounding boxes</span>
encoding = processor(image, words, boxes=boxes, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),wo=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJQcm9jZXNzb3IlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBMYXlvdXRMTXYyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiUyQyUyMHJldmlzaW9uJTNEJTIybm9fb2NyJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbiglMEElMjAlMjAlMjAlMjAlMjJuYW1lX29mX3lvdXJfZG9jdW1lbnQlMjAtJTIwY2FuJTIwYmUlMjBhJTIwcG5nJTJDJTIwanBnJTJDJTIwZXRjLiUyMG9mJTIweW91ciUyMGRvY3VtZW50cyUyMChQREZzJTIwbXVzdCUyMGJlJTIwY29udmVydGVkJTIwdG8lMjBpbWFnZXMpLiUyMiUwQSkuY29udmVydCglMjJSR0IlMjIpJTBBd29yZHMlMjAlM0QlMjAlNUIlMjJoZWxsbyUyMiUyQyUyMCUyMndvcmxkJTIyJTVEJTBBYm94ZXMlMjAlM0QlMjAlNUIlNUIxJTJDJTIwMiUyQyUyMDMlMkMlMjA0JTVEJTJDJTIwJTVCNSUyQyUyMDYlMkMlMjA3JTJDJTIwOCU1RCU1RCUyMCUyMCUyMyUyMG1ha2UlMjBzdXJlJTIwdG8lMjBub3JtYWxpemUlMjB5b3VyJTIwYm91bmRpbmclMjBib3hlcyUwQXdvcmRfbGFiZWxzJTIwJTNEJTIwJTVCMSUyQyUyMDIlNUQlMEFlbmNvZGluZyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZSUyQyUyMHdvcmRzJTJDJTIwYm94ZXMlM0Rib3hlcyUyQyUyMHdvcmRfbGFiZWxzJTNEd29yZF9sYWJlbHMlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXByaW50KGVuY29kaW5nLmtleXMoKSklMEElMjMlMjBkaWN0X2tleXMoJTVCJ2lucHV0X2lkcyclMkMlMjAndG9rZW5fdHlwZV9pZHMnJTJDJTIwJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdiYm94JyUyQyUyMCdsYWJlbHMnJTJDJTIwJ2ltYWdlJyU1RCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(
    <span class="hljs-string">&quot;name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
boxes = [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>], [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>]]  <span class="hljs-comment"># make sure to normalize your bounding boxes</span>
word_labels = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
encoding = processor(image, words, boxes=boxes, word_labels=word_labels, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;labels&#x27;, &#x27;image&#x27;])</span>`}}),Lo=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJQcm9jZXNzb3IlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBMYXlvdXRMTXYyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiklMEElMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4oJTBBJTIwJTIwJTIwJTIwJTIybmFtZV9vZl95b3VyX2RvY3VtZW50JTIwLSUyMGNhbiUyMGJlJTIwYSUyMHBuZyUyQyUyMGpwZyUyQyUyMGV0Yy4lMjBvZiUyMHlvdXIlMjBkb2N1bWVudHMlMjAoUERGcyUyMG11c3QlMjBiZSUyMGNvbnZlcnRlZCUyMHRvJTIwaW1hZ2VzKS4lMjIlMEEpLmNvbnZlcnQoJTIyUkdCJTIyKSUwQXF1ZXN0aW9uJTIwJTNEJTIwJTIyV2hhdCdzJTIwaGlzJTIwbmFtZSUzRiUyMiUwQWVuY29kaW5nJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlJTJDJTIwcXVlc3Rpb24lMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXByaW50KGVuY29kaW5nLmtleXMoKSklMEElMjMlMjBkaWN0X2tleXMoJTVCJ2lucHV0X2lkcyclMkMlMjAndG9rZW5fdHlwZV9pZHMnJTJDJTIwJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdiYm94JyUyQyUyMCdpbWFnZSclNUQp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(
    <span class="hljs-string">&quot;name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
question = <span class="hljs-string">&quot;What&#x27;s his name?&quot;</span>
encoding = processor(image, question, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),ko=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJQcm9jZXNzb3IlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBMYXlvdXRMTXYyUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMiUyQyUyMHJldmlzaW9uJTNEJTIybm9fb2NyJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbiglMEElMjAlMjAlMjAlMjAlMjJuYW1lX29mX3lvdXJfZG9jdW1lbnQlMjAtJTIwY2FuJTIwYmUlMjBhJTIwcG5nJTJDJTIwanBnJTJDJTIwZXRjLiUyMG9mJTIweW91ciUyMGRvY3VtZW50cyUyMChQREZzJTIwbXVzdCUyMGJlJTIwY29udmVydGVkJTIwdG8lMjBpbWFnZXMpLiUyMiUwQSkuY29udmVydCglMjJSR0IlMjIpJTBBcXVlc3Rpb24lMjAlM0QlMjAlMjJXaGF0J3MlMjBoaXMlMjBuYW1lJTNGJTIyJTBBd29yZHMlMjAlM0QlMjAlNUIlMjJoZWxsbyUyMiUyQyUyMCUyMndvcmxkJTIyJTVEJTBBYm94ZXMlMjAlM0QlMjAlNUIlNUIxJTJDJTIwMiUyQyUyMDMlMkMlMjA0JTVEJTJDJTIwJTVCNSUyQyUyMDYlMkMlMjA3JTJDJTIwOCU1RCU1RCUyMCUyMCUyMyUyMG1ha2UlMjBzdXJlJTIwdG8lMjBub3JtYWxpemUlMjB5b3VyJTIwYm91bmRpbmclMjBib3hlcyUwQWVuY29kaW5nJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlJTJDJTIwcXVlc3Rpb24lMkMlMjB3b3JkcyUyQyUyMGJveGVzJTNEYm94ZXMlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXByaW50KGVuY29kaW5nLmtleXMoKSklMEElMjMlMjBkaWN0X2tleXMoJTVCJ2lucHV0X2lkcyclMkMlMjAndG9rZW5fdHlwZV9pZHMnJTJDJTIwJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdiYm94JyUyQyUyMCdpbWFnZSclNUQp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2Processor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

processor = LayoutLMv2Processor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>, revision=<span class="hljs-string">&quot;no_ocr&quot;</span>)

image = Image.<span class="hljs-built_in">open</span>(
    <span class="hljs-string">&quot;name_of_your_document - can be a png, jpg, etc. of your documents (PDFs must be converted to images).&quot;</span>
).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
question = <span class="hljs-string">&quot;What&#x27;s his name?&quot;</span>
words = [<span class="hljs-string">&quot;hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
boxes = [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>], [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>]]  <span class="hljs-comment"># make sure to normalize your bounding boxes</span>
encoding = processor(image, question, words, boxes=boxes, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(encoding.keys())
<span class="hljs-comment"># dict_keys([&#x27;input_ids&#x27;, &#x27;token_type_ids&#x27;, &#x27;attention_mask&#x27;, &#x27;bbox&#x27;, &#x27;image&#x27;])</span>`}}),To=new Y({}),xo=new F({props:{name:"class transformers.LayoutLMv2Config",anchor:"transformers.LayoutLMv2Config",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 512"},{name:"type_vocab_size",val:" = 2"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"pad_token_id",val:" = 0"},{name:"max_2d_position_embeddings",val:" = 1024"},{name:"max_rel_pos",val:" = 128"},{name:"rel_pos_bins",val:" = 32"},{name:"fast_qkv",val:" = True"},{name:"max_rel_2d_pos",val:" = 256"},{name:"rel_2d_pos_bins",val:" = 64"},{name:"convert_sync_batchnorm",val:" = True"},{name:"image_feature_pool_shape",val:" = [7, 7, 256]"},{name:"coordinate_size",val:" = 128"},{name:"shape_size",val:" = 128"},{name:"has_relative_attention_bias",val:" = True"},{name:"has_spatial_attention_bias",val:" = True"},{name:"has_visual_segment_embedding",val:" = False"},{name:"detectron2_config_args",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2Config.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the LayoutLMv2 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/layoutlmv2#transformers.LayoutLMv2Model">LayoutLMv2Model</a> or <code>TFLayoutLMv2Model</code>.`,name:"vocab_size"},{anchor:"transformers.LayoutLMv2Config.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimension of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.LayoutLMv2Config.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.LayoutLMv2Config.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.LayoutLMv2Config.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.LayoutLMv2Config.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the 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> are supported.`,name:"hidden_act"},{anchor:"transformers.LayoutLMv2Config.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</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:"hidden_dropout_prob"},{anchor:"transformers.LayoutLMv2Config.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.LayoutLMv2Config.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.LayoutLMv2Config.type_vocab_size",description:`<strong>type_vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The vocabulary size of the <code>token_type_ids</code> passed when calling <a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model">LayoutLMv2Model</a> or
<code>TFLayoutLMv2Model</code>.`,name:"type_vocab_size"},{anchor:"transformers.LayoutLMv2Config.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.LayoutLMv2Config.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.LayoutLMv2Config.max_2d_position_embeddings",description:`<strong>max_2d_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum value that the 2D position embedding might ever be used with. Typically set this to something
large just in case (e.g., 1024).`,name:"max_2d_position_embeddings"},{anchor:"transformers.LayoutLMv2Config.max_rel_pos",description:`<strong>max_rel_pos</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The maximum number of relative positions to be used in the self-attention mechanism.`,name:"max_rel_pos"},{anchor:"transformers.LayoutLMv2Config.rel_pos_bins",description:`<strong>rel_pos_bins</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of relative position bins to be used in the self-attention mechanism.`,name:"rel_pos_bins"},{anchor:"transformers.LayoutLMv2Config.fast_qkv",description:`<strong>fast_qkv</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a single matrix for the queries, keys, values in the self-attention layers.`,name:"fast_qkv"},{anchor:"transformers.LayoutLMv2Config.max_rel_2d_pos",description:`<strong>max_rel_2d_pos</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
The maximum number of relative 2D positions in the self-attention mechanism.`,name:"max_rel_2d_pos"},{anchor:"transformers.LayoutLMv2Config.rel_2d_pos_bins",description:`<strong>rel_2d_pos_bins</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The number of 2D relative position bins in the self-attention mechanism.`,name:"rel_2d_pos_bins"},{anchor:"transformers.LayoutLMv2Config.image_feature_pool_shape",description:`<strong>image_feature_pool_shape</strong> (<code>List[int]</code>, <em>optional</em>, defaults to [7, 7, 256]) &#x2014;
The shape of the average-pooled feature map.`,name:"image_feature_pool_shape"},{anchor:"transformers.LayoutLMv2Config.coordinate_size",description:`<strong>coordinate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimension of the coordinate embeddings.`,name:"coordinate_size"},{anchor:"transformers.LayoutLMv2Config.shape_size",description:`<strong>shape_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimension of the width and height embeddings.`,name:"shape_size"},{anchor:"transformers.LayoutLMv2Config.has_relative_attention_bias",description:`<strong>has_relative_attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a relative attention bias in the self-attention mechanism.`,name:"has_relative_attention_bias"},{anchor:"transformers.LayoutLMv2Config.has_spatial_attention_bias",description:`<strong>has_spatial_attention_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a spatial attention bias in the self-attention mechanism.`,name:"has_spatial_attention_bias"},{anchor:"transformers.LayoutLMv2Config.has_visual_segment_embedding",description:`<strong>has_visual_segment_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add visual segment embeddings.`,name:"has_visual_segment_embedding"},{anchor:"transformers.LayoutLMv2Config.detectron2_config_args",description:`<strong>detectron2_config_args</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Dictionary containing the configuration arguments of the Detectron2 visual backbone. Refer to <a href="https://github.com/microsoft/unilm/blob/master/layoutlmft/layoutlmft/models/layoutlmv2/detectron2_config.py" rel="nofollow">this
file</a>
for details regarding default values.`,name:"detectron2_config_args"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/configuration_layoutlmv2.py#L34"}}),ot=new Ps({props:{anchor:"transformers.LayoutLMv2Config.example",$$slots:{default:[xb]},$$scope:{ctx:I}}}),Jo=new Y({}),Uo=new F({props:{name:"class transformers.LayoutLMv2FeatureExtractor",anchor:"transformers.LayoutLMv2FeatureExtractor",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py#L28"}}),Eo=new F({props:{name:"__call__",anchor:"transformers.LayoutLMv2FeatureExtractor.__call__",parameters:[{name:"images",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/image_processing_utils.py#L462"}}),zo=new Y({}),Io=new F({props:{name:"class transformers.LayoutLMv2ImageProcessor",anchor:"transformers.LayoutLMv2ImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"apply_ocr",val:": bool = True"},{name:"ocr_lang",val:": typing.Optional[str] = None"},{name:"tesseract_config",val:": typing.Optional[str] = ''"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to <code>(size[&quot;height&quot;], size[&quot;width&quot;])</code>. Can be
overridden by <code>do_resize</code> in <code>preprocess</code>.`,name:"do_resize"},{anchor:"transformers.LayoutLMv2ImageProcessor.size",description:`<strong>size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>{&quot;height&quot; -- 224, &quot;width&quot;: 224}</code>):
Size of the image after resizing. Can be overridden by <code>size</code> in <code>preprocess</code>.`,name:"size"},{anchor:"transformers.LayoutLMv2ImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by the <code>resample</code> parameter in the
<code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.LayoutLMv2ImageProcessor.apply_ocr",description:`<strong>apply_ocr</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to apply the Tesseract OCR engine to get words + normalized bounding boxes. Can be overridden by
<code>apply_ocr</code> in <code>preprocess</code>.`,name:"apply_ocr"},{anchor:"transformers.LayoutLMv2ImageProcessor.ocr_lang",description:`<strong>ocr_lang</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The language, specified by its ISO code, to be used by the Tesseract OCR engine. By default, English is
used. Can be overridden by <code>ocr_lang</code> in <code>preprocess</code>.`,name:"ocr_lang"},{anchor:"transformers.LayoutLMv2ImageProcessor.tesseract_config",description:`<strong>tesseract_config</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Any additional custom configuration flags that are forwarded to the <code>config</code> parameter when calling
Tesseract. For example: &#x2018;&#x2014;psm 6&#x2019;. Can be overridden by <code>tesseract_config</code> in <code>preprocess</code>.`,name:"tesseract_config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/image_processing_layoutlmv2.py#L87"}}),Co=new F({props:{name:"preprocess",anchor:"transformers.LayoutLMv2ImageProcessor.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:"do_resize",val:": bool = None"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = None"},{name:"apply_ocr",val:": bool = None"},{name:"ocr_lang",val:": typing.Optional[str] = None"},{name:"tesseract_config",val:": typing.Optional[str] = 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.LayoutLMv2ImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess.`,name:"images"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Desired size of the output image after resizing.`,name:"size"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PIL.Image</code> resampling
filter. Only has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.apply_ocr",description:`<strong>apply_ocr</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.apply_ocr</code>) &#x2014;
Whether to apply the Tesseract OCR engine to get words + normalized bounding boxes.`,name:"apply_ocr"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.ocr_lang",description:`<strong>ocr_lang</strong> (<code>str</code>, <em>optional</em>, defaults to <code>self.ocr_lang</code>) &#x2014;
The language, specified by its ISO code, to be used by the Tesseract OCR engine. By default, English is
used.`,name:"ocr_lang"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.tesseract_config",description:`<strong>tesseract_config</strong> (<code>str</code>, <em>optional</em>, defaults to <code>self.tesseract_config</code>) &#x2014;
Any additional custom configuration flags that are forwarded to the <code>config</code> parameter when calling
Tesseract.`,name:"tesseract_config"},{anchor:"transformers.LayoutLMv2ImageProcessor.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"},{anchor:"transformers.LayoutLMv2ImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/image_processing_layoutlmv2.py#L161"}}),$o=new Y({}),Fo=new F({props:{name:"class transformers.LayoutLMv2Tokenizer",anchor:"transformers.LayoutLMv2Tokenizer",parameters:[{name:"vocab_file",val:""},{name:"do_lower_case",val:" = True"},{name:"do_basic_tokenize",val:" = True"},{name:"never_split",val:" = None"},{name:"unk_token",val:" = '[UNK]'"},{name:"sep_token",val:" = '[SEP]'"},{name:"pad_token",val:" = '[PAD]'"},{name:"cls_token",val:" = '[CLS]'"},{name:"mask_token",val:" = '[MASK]'"},{name:"cls_token_box",val:" = [0, 0, 0, 0]"},{name:"sep_token_box",val:" = [1000, 1000, 1000, 1000]"},{name:"pad_token_box",val:" = [0, 0, 0, 0]"},{name:"pad_token_label",val:" = -100"},{name:"only_label_first_subword",val:" = True"},{name:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"model_max_length",val:": int = 512"},{name:"additional_special_tokens",val:": typing.Optional[typing.List[str]] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L206"}}),Wo=new F({props:{name:"__call__",anchor:"transformers.LayoutLMv2Tokenizer.__call__",parameters:[{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]]"},{name:"text_pair",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] = None"},{name:"boxes",val:": typing.Union[typing.List[typing.List[int]], typing.List[typing.List[typing.List[int]]]] = None"},{name:"word_labels",val:": typing.Union[typing.List[int], typing.List[typing.List[int]], NoneType] = None"},{name:"add_special_tokens",val:": bool = True"},{name:"padding",val:": typing.Union[bool, str, transformers.utils.generic.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"stride",val:": int = 0"},{name:"pad_to_multiple_of",val:": typing.Optional[int] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"return_token_type_ids",val:": typing.Optional[bool] = None"},{name:"return_attention_mask",val:": typing.Optional[bool] = None"},{name:"return_overflowing_tokens",val:": bool = False"},{name:"return_special_tokens_mask",val:": bool = False"},{name:"return_offsets_mapping",val:": bool = False"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2Tokenizer.__call__.text",description:`<strong>text</strong> (<code>str</code>, <code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string, a list of strings
(words of a single example or questions of a batch of examples) or a list of list of strings (batch of
words).`,name:"text"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.text_pair",description:`<strong>text_pair</strong> (<code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence should be a list of strings
(pretokenized string).`,name:"text_pair"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.boxes",description:`<strong>boxes</strong> (<code>List[List[int]]</code>, <code>List[List[List[int]]]</code>) &#x2014;
Word-level bounding boxes. Each bounding box should be normalized to be on a 0-1000 scale.`,name:"boxes"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.word_labels",description:`<strong>word_labels</strong> (<code>List[int]</code>, <code>List[List[int]]</code>, <em>optional</em>) &#x2014;
Word-level integer labels (for token classification tasks such as FUNSD, CORD).`,name:"word_labels"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to encode the sequences with the special tokens relative to their model.`,name:"add_special_tokens"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.padding",description:`<strong>padding</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/v4.30.0/en/internal/file_utils#transformers.utils.PaddingStrategy">PaddingStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls padding. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest&apos;</code>: Pad to the longest sequence in the batch (or no padding if only a single
sequence if provided).</li>
<li><code>&apos;max_length&apos;</code>: Pad to a maximum length specified with the argument <code>max_length</code> or to the maximum
acceptable input length for the model if that argument is not provided.</li>
<li><code>False</code> or <code>&apos;do_not_pad&apos;</code> (default): No padding (i.e., can output a batch with sequences of different
lengths).</li>
</ul>`,name:"padding"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.truncation",description:`<strong>truncation</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.tokenization_utils_base.TruncationStrategy">TruncationStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls truncation. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or
to the maximum acceptable input length for the model if that argument is not provided. This will
truncate token by token, removing a token from the longest sequence in the pair if a pair of
sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the first sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_second&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the second sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>False</code> or <code>&apos;do_not_truncate&apos;</code> (default): No truncation (i.e., can output batch with sequence lengths
greater than the model maximum admissible input size).</li>
</ul>`,name:"truncation"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Controls the maximum length to use by one of the truncation/padding parameters.</p>
<p>If left unset or set to <code>None</code>, this will use the predefined model maximum length if a maximum length
is required by one of the truncation/padding parameters. If the model has no specific maximum input
length (like XLNet) truncation/padding to a maximum length will be deactivated.`,name:"max_length"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.stride",description:`<strong>stride</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to a number along with <code>max_length</code>, the overflowing tokens returned when
<code>return_overflowing_tokens=True</code> will contain some tokens from the end of the truncated sequence
returned to provide some overlap between truncated and overflowing sequences. The value of this
argument defines the number of overlapping tokens.`,name:"stride"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.pad_to_multiple_of",description:`<strong>pad_to_multiple_of</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If set will pad the sequence to a multiple of the provided value. This is especially useful to enable
the use of Tensor Cores on NVIDIA hardware with compute capability <code>&gt;= 7.5</code> (Volta).`,name:"pad_to_multiple_of"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/v4.30.0/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors instead of list of python integers. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return Numpy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_token_type_ids",description:`<strong>return_token_type_ids</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return token type IDs. If left to the default, will return the token type IDs according to
the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"return_token_type_ids"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_attention_mask",description:`<strong>return_attention_mask</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return the attention mask. If left to the default, will return the attention mask according
to the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"return_attention_mask"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_overflowing_tokens",description:`<strong>return_overflowing_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return overflowing token sequences. If a pair of sequences of input ids (or a batch
of pairs) is provided with <code>truncation_strategy = longest_first</code> or <code>True</code>, an error is raised instead
of returning overflowing tokens.`,name:"return_overflowing_tokens"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_special_tokens_mask",description:`<strong>return_special_tokens_mask</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return special tokens mask information.`,name:"return_special_tokens_mask"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_offsets_mapping",description:`<strong>return_offsets_mapping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return <code>(char_start, char_end)</code> for each token.</p>
<p>This is only available on fast tokenizers inheriting from <a href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast">PreTrainedTokenizerFast</a>, if using
Python&#x2019;s tokenizer, this method will raise <code>NotImplementedError</code>.`,name:"return_offsets_mapping"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.return_length",description:`<strong>return_length</strong>  (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the lengths of the encoded inputs.`,name:"return_length"},{anchor:"transformers.LayoutLMv2Tokenizer.__call__.verbose",description:`<strong>verbose</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to print more information and warnings.
**kwargs &#x2014; passed to the <code>self.tokenize()</code> method`,name:"verbose"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L425",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a> with the following fields:</p>
<ul>
<li>
<p><strong>input_ids</strong> \u2014 List of token ids to be fed to a model.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
</li>
<li>
<p><strong>bbox</strong> \u2014 List of bounding boxes to be fed to a model.</p>
</li>
<li>
<p><strong>token_type_ids</strong> \u2014 List of token type ids to be fed to a model (when <code>return_token_type_ids=True</code> or
if <em>\u201Ctoken_type_ids\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a></p>
</li>
<li>
<p><strong>attention_mask</strong> \u2014 List of indices specifying which tokens should be attended to by the model (when
<code>return_attention_mask=True</code> or if <em>\u201Cattention_mask\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
</li>
<li>
<p><strong>labels</strong> \u2014 List of labels to be fed to a model. (when <code>word_labels</code> is specified).</p>
</li>
<li>
<p><strong>overflowing_tokens</strong> \u2014 List of overflowing tokens sequences (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>num_truncated_tokens</strong> \u2014 Number of tokens truncated (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>special_tokens_mask</strong> \u2014 List of 0s and 1s, with 1 specifying added special tokens and 0 specifying
regular sequence tokens (when <code>add_special_tokens=True</code> and <code>return_special_tokens_mask=True</code>).</p>
</li>
<li>
<p><strong>length</strong> \u2014 The length of the inputs (when <code>return_length=True</code>).</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),Ro=new F({props:{name:"save_vocabulary",anchor:"transformers.LayoutLMv2Tokenizer.save_vocabulary",parameters:[{name:"save_directory",val:": str"},{name:"filename_prefix",val:": typing.Optional[str] = None"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L405"}}),No=new Y({}),qo=new F({props:{name:"class transformers.LayoutLMv2TokenizerFast",anchor:"transformers.LayoutLMv2TokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"do_lower_case",val:" = True"},{name:"unk_token",val:" = '[UNK]'"},{name:"sep_token",val:" = '[SEP]'"},{name:"pad_token",val:" = '[PAD]'"},{name:"cls_token",val:" = '[CLS]'"},{name:"mask_token",val:" = '[MASK]'"},{name:"cls_token_box",val:" = [0, 0, 0, 0]"},{name:"sep_token_box",val:" = [1000, 1000, 1000, 1000]"},{name:"pad_token_box",val:" = [0, 0, 0, 0]"},{name:"pad_token_label",val:" = -100"},{name:"only_label_first_subword",val:" = True"},{name:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2TokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.LayoutLMv2TokenizerFast.do_lower_case",description:`<strong>do_lower_case</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to lowercase the input when tokenizing.`,name:"do_lower_case"},{anchor:"transformers.LayoutLMv2TokenizerFast.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[UNK]&quot;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.sep_token",description:`<strong>sep_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[SEP]&quot;</code>) &#x2014;
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.`,name:"sep_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[PAD]&quot;</code>) &#x2014;
The token used for padding, for example when batching sequences of different lengths.`,name:"pad_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.cls_token",description:`<strong>cls_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[CLS]&quot;</code>) &#x2014;
The classifier token which is used when doing sequence classification (classification of the whole sequence
instead of per-token classification). It is the first token of the sequence when built with special tokens.`,name:"cls_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.mask_token",description:`<strong>mask_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;[MASK]&quot;</code>) &#x2014;
The token used for masking values. This is the token used when training this model with masked language
modeling. This is the token which the model will try to predict.`,name:"mask_token"},{anchor:"transformers.LayoutLMv2TokenizerFast.cls_token_box",description:`<strong>cls_token_box</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[0, 0, 0, 0]</code>) &#x2014;
The bounding box to use for the special [CLS] token.`,name:"cls_token_box"},{anchor:"transformers.LayoutLMv2TokenizerFast.sep_token_box",description:`<strong>sep_token_box</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[1000, 1000, 1000, 1000]</code>) &#x2014;
The bounding box to use for the special [SEP] token.`,name:"sep_token_box"},{anchor:"transformers.LayoutLMv2TokenizerFast.pad_token_box",description:`<strong>pad_token_box</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[0, 0, 0, 0]</code>) &#x2014;
The bounding box to use for the special [PAD] token.`,name:"pad_token_box"},{anchor:"transformers.LayoutLMv2TokenizerFast.pad_token_label",description:`<strong>pad_token_label</strong> (<code>int</code>, <em>optional</em>, defaults to -100) &#x2014;
The label to use for padding tokens. Defaults to -100, which is the <code>ignore_index</code> of PyTorch&#x2019;s
CrossEntropyLoss.`,name:"pad_token_label"},{anchor:"transformers.LayoutLMv2TokenizerFast.only_label_first_subword",description:`<strong>only_label_first_subword</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to only label the first subword, in case word labels are provided.`,name:"only_label_first_subword"},{anchor:"transformers.LayoutLMv2TokenizerFast.tokenize_chinese_chars",description:`<strong>tokenize_chinese_chars</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to tokenize Chinese characters. This should likely be deactivated for Japanese (see <a href="https://github.com/huggingface/transformers/issues/328" rel="nofollow">this
issue</a>).`,name:"tokenize_chinese_chars"},{anchor:"transformers.LayoutLMv2TokenizerFast.strip_accents",description:`<strong>strip_accents</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to strip all accents. If this option is not specified, then it will be determined by the
value for <code>lowercase</code> (as in the original LayoutLMv2).`,name:"strip_accents"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L70"}}),Xo=new F({props:{name:"__call__",anchor:"transformers.LayoutLMv2TokenizerFast.__call__",parameters:[{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]]"},{name:"text_pair",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] = None"},{name:"boxes",val:": typing.Union[typing.List[typing.List[int]], typing.List[typing.List[typing.List[int]]]] = None"},{name:"word_labels",val:": typing.Union[typing.List[int], typing.List[typing.List[int]], NoneType] = None"},{name:"add_special_tokens",val:": bool = True"},{name:"padding",val:": typing.Union[bool, str, transformers.utils.generic.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"stride",val:": int = 0"},{name:"pad_to_multiple_of",val:": typing.Optional[int] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"return_token_type_ids",val:": typing.Optional[bool] = None"},{name:"return_attention_mask",val:": typing.Optional[bool] = None"},{name:"return_overflowing_tokens",val:": bool = False"},{name:"return_special_tokens_mask",val:": bool = False"},{name:"return_offsets_mapping",val:": bool = False"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.text",description:`<strong>text</strong> (<code>str</code>, <code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence can be a string, a list of strings
(words of a single example or questions of a batch of examples) or a list of list of strings (batch of
words).`,name:"text"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.text_pair",description:`<strong>text_pair</strong> (<code>List[str]</code>, <code>List[List[str]]</code>) &#x2014;
The sequence or batch of sequences to be encoded. Each sequence should be a list of strings
(pretokenized string).`,name:"text_pair"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.boxes",description:`<strong>boxes</strong> (<code>List[List[int]]</code>, <code>List[List[List[int]]]</code>) &#x2014;
Word-level bounding boxes. Each bounding box should be normalized to be on a 0-1000 scale.`,name:"boxes"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.word_labels",description:`<strong>word_labels</strong> (<code>List[int]</code>, <code>List[List[int]]</code>, <em>optional</em>) &#x2014;
Word-level integer labels (for token classification tasks such as FUNSD, CORD).`,name:"word_labels"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.add_special_tokens",description:`<strong>add_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to encode the sequences with the special tokens relative to their model.`,name:"add_special_tokens"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.padding",description:`<strong>padding</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/v4.30.0/en/internal/file_utils#transformers.utils.PaddingStrategy">PaddingStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls padding. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest&apos;</code>: Pad to the longest sequence in the batch (or no padding if only a single
sequence if provided).</li>
<li><code>&apos;max_length&apos;</code>: Pad to a maximum length specified with the argument <code>max_length</code> or to the maximum
acceptable input length for the model if that argument is not provided.</li>
<li><code>False</code> or <code>&apos;do_not_pad&apos;</code> (default): No padding (i.e., can output a batch with sequences of different
lengths).</li>
</ul>`,name:"padding"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.truncation",description:`<strong>truncation</strong> (<code>bool</code>, <code>str</code> or <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.tokenization_utils_base.TruncationStrategy">TruncationStrategy</a>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Activates and controls truncation. Accepts the following values:</p>
<ul>
<li><code>True</code> or <code>&apos;longest_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or
to the maximum acceptable input length for the model if that argument is not provided. This will
truncate token by token, removing a token from the longest sequence in the pair if a pair of
sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_first&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the first sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>&apos;only_second&apos;</code>: Truncate to a maximum length specified with the argument <code>max_length</code> or to the
maximum acceptable input length for the model if that argument is not provided. This will only
truncate the second sequence of a pair if a pair of sequences (or a batch of pairs) is provided.</li>
<li><code>False</code> or <code>&apos;do_not_truncate&apos;</code> (default): No truncation (i.e., can output batch with sequence lengths
greater than the model maximum admissible input size).</li>
</ul>`,name:"truncation"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Controls the maximum length to use by one of the truncation/padding parameters.</p>
<p>If left unset or set to <code>None</code>, this will use the predefined model maximum length if a maximum length
is required by one of the truncation/padding parameters. If the model has no specific maximum input
length (like XLNet) truncation/padding to a maximum length will be deactivated.`,name:"max_length"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.stride",description:`<strong>stride</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to a number along with <code>max_length</code>, the overflowing tokens returned when
<code>return_overflowing_tokens=True</code> will contain some tokens from the end of the truncated sequence
returned to provide some overlap between truncated and overflowing sequences. The value of this
argument defines the number of overlapping tokens.`,name:"stride"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.pad_to_multiple_of",description:`<strong>pad_to_multiple_of</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If set will pad the sequence to a multiple of the provided value. This is especially useful to enable
the use of Tensor Cores on NVIDIA hardware with compute capability <code>&gt;= 7.5</code> (Volta).`,name:"pad_to_multiple_of"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <a href="/docs/transformers/v4.30.0/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
If set, will return tensors instead of list of python integers. Acceptable values are:</p>
<ul>
<li><code>&apos;tf&apos;</code>: Return TensorFlow <code>tf.constant</code> objects.</li>
<li><code>&apos;pt&apos;</code>: Return PyTorch <code>torch.Tensor</code> objects.</li>
<li><code>&apos;np&apos;</code>: Return Numpy <code>np.ndarray</code> objects.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_token_type_ids",description:`<strong>return_token_type_ids</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return token type IDs. If left to the default, will return the token type IDs according to
the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"return_token_type_ids"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_attention_mask",description:`<strong>return_attention_mask</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to return the attention mask. If left to the default, will return the attention mask according
to the specific tokenizer&#x2019;s default, defined by the <code>return_outputs</code> attribute.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"return_attention_mask"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_overflowing_tokens",description:`<strong>return_overflowing_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return overflowing token sequences. If a pair of sequences of input ids (or a batch
of pairs) is provided with <code>truncation_strategy = longest_first</code> or <code>True</code>, an error is raised instead
of returning overflowing tokens.`,name:"return_overflowing_tokens"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_special_tokens_mask",description:`<strong>return_special_tokens_mask</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return special tokens mask information.`,name:"return_special_tokens_mask"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_offsets_mapping",description:`<strong>return_offsets_mapping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return <code>(char_start, char_end)</code> for each token.</p>
<p>This is only available on fast tokenizers inheriting from <a href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast">PreTrainedTokenizerFast</a>, if using
Python&#x2019;s tokenizer, this method will raise <code>NotImplementedError</code>.`,name:"return_offsets_mapping"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.return_length",description:`<strong>return_length</strong>  (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the lengths of the encoded inputs.`,name:"return_length"},{anchor:"transformers.LayoutLMv2TokenizerFast.__call__.verbose",description:`<strong>verbose</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to print more information and warnings.
**kwargs &#x2014; passed to the <code>self.tokenize()</code> method`,name:"verbose"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L179",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a> with the following fields:</p>
<ul>
<li>
<p><strong>input_ids</strong> \u2014 List of token ids to be fed to a model.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
</li>
<li>
<p><strong>bbox</strong> \u2014 List of bounding boxes to be fed to a model.</p>
</li>
<li>
<p><strong>token_type_ids</strong> \u2014 List of token type ids to be fed to a model (when <code>return_token_type_ids=True</code> or
if <em>\u201Ctoken_type_ids\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a></p>
</li>
<li>
<p><strong>attention_mask</strong> \u2014 List of indices specifying which tokens should be attended to by the model (when
<code>return_attention_mask=True</code> or if <em>\u201Cattention_mask\u201D</em> is in <code>self.model_input_names</code>).</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a></p>
</li>
<li>
<p><strong>labels</strong> \u2014 List of labels to be fed to a model. (when <code>word_labels</code> is specified).</p>
</li>
<li>
<p><strong>overflowing_tokens</strong> \u2014 List of overflowing tokens sequences (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>num_truncated_tokens</strong> \u2014 Number of tokens truncated (when a <code>max_length</code> is specified and
<code>return_overflowing_tokens=True</code>).</p>
</li>
<li>
<p><strong>special_tokens_mask</strong> \u2014 List of 0s and 1s, with 1 specifying added special tokens and 0 specifying
regular sequence tokens (when <code>add_special_tokens=True</code> and <code>return_special_tokens_mask=True</code>).</p>
</li>
<li>
<p><strong>length</strong> \u2014 The length of the inputs (when <code>return_length=True</code>).</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),Vo=new Y({}),Go=new F({props:{name:"class transformers.LayoutLMv2Processor",anchor:"transformers.LayoutLMv2Processor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2Processor.image_processor",description:`<strong>image_processor</strong> (<code>LayoutLMv2ImageProcessor</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor">LayoutLMv2ImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.LayoutLMv2Processor.tokenizer",description:`<strong>tokenizer</strong> (<code>LayoutLMv2Tokenizer</code> or <code>LayoutLMv2TokenizerFast</code>) &#x2014;
An instance of <a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</a> or <a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast">LayoutLMv2TokenizerFast</a>. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L27"}}),So=new F({props:{name:"__call__",anchor:"transformers.LayoutLMv2Processor.__call__",parameters:[{name:"images",val:""},{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]] = None"},{name:"text_pair",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] = None"},{name:"boxes",val:": typing.Union[typing.List[typing.List[int]], typing.List[typing.List[typing.List[int]]]] = None"},{name:"word_labels",val:": typing.Union[typing.List[int], typing.List[typing.List[int]], NoneType] = None"},{name:"add_special_tokens",val:": bool = True"},{name:"padding",val:": typing.Union[bool, str, transformers.utils.generic.PaddingStrategy] = False"},{name:"truncation",val:": typing.Union[bool, str, transformers.tokenization_utils_base.TruncationStrategy] = False"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"stride",val:": int = 0"},{name:"pad_to_multiple_of",val:": typing.Optional[int] = None"},{name:"return_token_type_ids",val:": typing.Optional[bool] = None"},{name:"return_attention_mask",val:": typing.Optional[bool] = None"},{name:"return_overflowing_tokens",val:": bool = False"},{name:"return_special_tokens_mask",val:": bool = False"},{name:"return_offsets_mapping",val:": bool = False"},{name:"return_length",val:": bool = False"},{name:"verbose",val:": bool = True"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L67"}}),Qo=new Y({}),Yo=new F({props:{name:"class transformers.LayoutLMv2Model",anchor:"transformers.LayoutLMv2Model",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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/layoutlmv2/modeling_layoutlmv2.py#L709"}}),Ko=new F({props:{name:"forward",anchor:"transformers.LayoutLMv2Model.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = 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.LayoutLMv2Model.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.</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#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LayoutLMv2Model.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>((batch_size, sequence_length), 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2Model.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2Model.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.LayoutLMv2Model.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMv2Model.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LayoutLMv2Model.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.LayoutLMv2Model.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2Model.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.LayoutLMv2Model.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.LayoutLMv2Model.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/layoutlmv2/modeling_layoutlmv2.py#L819",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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>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.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),mt=new Pi({props:{$$slots:{default:[jb]},$$scope:{ctx:I}}}),ht=new Ps({props:{anchor:"transformers.LayoutLMv2Model.forward.example",$$slots:{default:[Jb]},$$scope:{ctx:I}}}),en=new Y({}),tn=new F({props:{name:"class transformers.LayoutLMv2ForSequenceClassification",anchor:"transformers.LayoutLMv2ForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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/layoutlmv2/modeling_layoutlmv2.py#L970"}}),rn=new F({props:{name:"forward",anchor:"transformers.LayoutLMv2ForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = 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.LayoutLMv2ForSequenceClassification.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.</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#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length, 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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.LayoutLMv2ForSequenceClassification.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"},{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L984",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),gt=new Pi({props:{$$slots:{default:[Ub]},$$scope:{ctx:I}}}),yt=new Ps({props:{anchor:"transformers.LayoutLMv2ForSequenceClassification.forward.example",$$slots:{default:[Eb]},$$scope:{ctx:I}}}),ln=new Y({}),cn=new F({props:{name:"class transformers.LayoutLMv2ForTokenClassification",anchor:"transformers.LayoutLMv2ForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMv2ForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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/layoutlmv2/modeling_layoutlmv2.py#L1151"}}),gn=new F({props:{name:"forward",anchor:"transformers.LayoutLMv2ForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = 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.LayoutLMv2ForTokenClassification.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.</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#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length, 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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.LayoutLMv2ForTokenClassification.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"},{anchor:"transformers.LayoutLMv2ForTokenClassification.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 token classification loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1165",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),vt=new Pi({props:{$$slots:{default:[zb]},$$scope:{ctx:I}}}),bt=new Ps({props:{anchor:"transformers.LayoutLMv2ForTokenClassification.forward.example",$$slots:{default:[Ib]},$$scope:{ctx:I}}}),yn=new Y({}),_n=new F({props:{name:"class transformers.LayoutLMv2ForQuestionAnswering",anchor:"transformers.LayoutLMv2ForQuestionAnswering",parameters:[{name:"config",val:""},{name:"has_visual_segment_embedding",val:" = True"}],parametersDescription:[{anchor:"transformers.LayoutLMv2ForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config">LayoutLMv2Config</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/layoutlmv2/modeling_layoutlmv2.py#L1282"}}),wn=new F({props:{name:"forward",anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = None"},{name:"image",val:": typing.Optional[torch.FloatTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = 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.LayoutLMv2ForQuestionAnswering.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.</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#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.bbox",description:`<strong>bbox</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length, 4)</code>, <em>optional</em>) &#x2014;
Bounding boxes of each input sequence tokens. Selected in the range <code>[0, config.max_2d_position_embeddings-1]</code>. Each bounding box should be a normalized version in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1,
y1) represents the position of the lower right corner.`,name:"bbox"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>detectron.structures.ImageList</code> whose <code>tensors</code> is of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Batch of document images.`,name:"image"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>batch_size, sequence_length</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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 <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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.LayoutLMv2ForQuestionAnswering.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"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1296",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</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/layoutlmv2#transformers.LayoutLMv2Config"
>LayoutLMv2Config</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 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end scores (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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),wt=new Pi({props:{$$slots:{default:[Cb]},$$scope:{ctx:I}}}),Lt=new Ps({props:{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.example",$$slots:{default:[$b]},$$scope:{ctx:I}}}),kt=new Ps({props:{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.example-2",$$slots:{default:[Fb]},$$scope:{ctx:I}}}),{c(){h=a("meta"),k=d(),f=a("h1"),w=a("a"),T=a("span"),g(m.$$.fragment),L=d(),R=a("span"),Di=n("LayoutLMV2"),Or=d(),je=a("h2"),Qe=a("a"),Qs=a("span"),g(Ft.$$.fragment),Qi=d(),Ys=a("span"),Yi=n("Overview"),Hr=d(),me=a("p"),Oi=n("The LayoutLMV2 model was proposed in "),Zt=a("a"),Hi=n("LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding"),Ki=n(` by Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu,
Dinei Florencio, Cha Zhang, Wanxiang Che, Min Zhang, Lidong Zhou. LayoutLMV2 improves `),Tn=a("a"),ec=n("LayoutLM"),tc=n(` to obtain
state-of-the-art results across several document image understanding benchmarks:`),Kr=d(),he=a("ul"),O=a("li"),oc=n("information extraction from scanned documents: the "),Wt=a("a"),nc=n("FUNSD"),sc=n(` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),Rt=a("a"),ac=n("CORD"),rc=n(`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),Nt=a("a"),lc=n("SROIE"),ic=n(` dataset (a collection of 626 receipts for training and 347 receipts for testing)
and the `),qt=a("a"),cc=n("Kleister-NDA"),dc=n(` dataset (a collection of non-disclosure
agreements from the EDGAR database, including 254 documents for training, 83 documents for validation, and 203
documents for testing).`),pc=d(),Bt=a("li"),uc=n("document image classification: the "),At=a("a"),mc=n("RVL-CDIP"),hc=n(` dataset (a collection of
400,000 images belonging to one of 16 classes).`),fc=d(),Xt=a("li"),gc=n("document visual question answering: the "),Vt=a("a"),yc=n("DocVQA"),_c=n(` dataset (a collection of 50,000
questions defined on 12,000+ document images).`),el=d(),xn=a("p"),vc=n("The abstract from the paper is the following:"),tl=d(),jn=a("p"),Os=a("em"),bc=n(`Pre-training of text and layout has proved effective in a variety of visually-rich document understanding tasks due to
its effective model architecture and the advantage of large-scale unlabeled scanned/digital-born documents. In this
paper, we present LayoutLMv2 by pre-training text, layout and image in a multi-modal framework, where new model
architectures and pre-training tasks are leveraged. Specifically, LayoutLMv2 not only uses the existing masked
visual-language modeling task but also the new text-image alignment and text-image matching tasks in the pre-training
stage, where cross-modality interaction is better learned. Meanwhile, it also integrates a spatial-aware self-attention
mechanism into the Transformer architecture, so that the model can fully understand the relative positional
relationship among different text blocks. Experiment results show that LayoutLMv2 outperforms strong baselines and
achieves new state-of-the-art results on a wide variety of downstream visually-rich document understanding tasks,
including FUNSD (0.7895 -> 0.8420), CORD (0.9493 -> 0.9601), SROIE (0.9524 -> 0.9781), Kleister-NDA (0.834 -> 0.852),
RVL-CDIP (0.9443 -> 0.9564), and DocVQA (0.7295 -> 0.8672). The pre-trained LayoutLMv2 model is publicly available at
this https URL.`),ol=d(),se=a("p"),Mc=n("LayoutLMv2 depends on "),Hs=a("code"),wc=n("detectron2"),Lc=n(", "),Ks=a("code"),kc=n("torchvision"),Tc=n(" and "),ea=a("code"),xc=n("tesseract"),jc=n(`. Run the
following to install them:`),nl=d(),g(Gt.$$.fragment),sl=d(),Jn=a("p"),Jc=n("(If you are developing for LayoutLMv2, note that passing the doctests also requires the installation of these packages.)"),al=d(),Un=a("p"),Uc=n("Tips:"),rl=d(),G=a("ul"),ta=a("li"),Ec=n(`The main difference between LayoutLMv1 and LayoutLMv2 is that the latter incorporates visual embeddings during
pre-training (while LayoutLMv1 only adds visual embeddings during fine-tuning).`),zc=d(),St=a("li"),Ic=n(`LayoutLMv2 adds both a relative 1D attention bias as well as a spatial 2D attention bias to the attention scores in
the self-attention layers. Details can be found on page 5 of the `),Pt=a("a"),Cc=n("paper"),$c=n("."),Fc=d(),Dt=a("li"),Zc=n("Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),Qt=a("a"),Wc=n("here"),Rc=n("."),Nc=d(),Je=a("li"),qc=n("LayoutLMv2 uses Facebook AI\u2019s "),Yt=a("a"),Bc=n("Detectron2"),Ac=n(` package for its visual
backbone. See `),Ot=a("a"),Xc=n("this link"),Vc=n(` for installation
instructions.`),Gc=d(),x=a("li"),Sc=n("In addition to "),oa=a("code"),Pc=n("input_ids"),Dc=n(", "),En=a("a"),Qc=n("forward()"),Yc=n(` expects 2 additional inputs, namely
`),na=a("code"),Oc=n("image"),Hc=n(" and "),sa=a("code"),Kc=n("bbox"),ed=n(". The "),aa=a("code"),td=n("image"),od=n(` input corresponds to the original document image in which the text
tokens occur. The model expects each document image to be of size 224x224. This means that if you have a batch of
document images, `),ra=a("code"),nd=n("image"),sd=n(` should be a tensor of shape (batch_size, 3, 224, 224). This can be either a
`),la=a("code"),ad=n("torch.Tensor"),rd=n(" or a "),ia=a("code"),ld=n("Detectron2.structures.ImageList"),id=n(`. You don\u2019t need to normalize the channels, as this is
done by the model. Important to note is that the visual backbone expects BGR channels instead of RGB, as all models
in Detectron2 are pre-trained using the BGR format. The `),ca=a("code"),cd=n("bbox"),dd=n(` input are the bounding boxes (i.e. 2D-positions)
of the input text tokens. This is identical to `),zn=a("a"),pd=n("LayoutLMModel"),ud=n(`. These can be obtained using an
external OCR engine such as Google\u2019s `),Ht=a("a"),md=n("Tesseract"),hd=n(" (there\u2019s a "),Kt=a("a"),fd=n(`Python
wrapper`),gd=n(` available). Each bounding box should be in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1, y1)
represents the position of the lower right corner. Note that one first needs to normalize the bounding boxes to be on
a 0-1000 scale. To normalize, you can use the following function:`),ll=d(),g(eo.$$.fragment),il=d(),fe=a("p"),yd=n("Here, "),da=a("code"),_d=n("width"),vd=n(" and "),pa=a("code"),bd=n("height"),Md=n(` correspond to the width and height of the original document in which the token
occurs (before resizing the image). Those can be obtained using the Python Image Library (PIL) library for example, as
follows:`),cl=d(),g(to.$$.fragment),dl=d(),Ye=a("p"),wd=n("However, this model includes a brand new "),In=a("a"),Ld=n("LayoutLMv2Processor"),kd=n(` which can be used to directly
prepare data for the model (including applying OCR under the hood). More information can be found in the \u201CUsage\u201D
section below.`),pl=d(),ge=a("ul"),Z=a("li"),Td=n("Internally, "),Cn=a("a"),xd=n("LayoutLMv2Model"),jd=n(" will send the "),ua=a("code"),Jd=n("image"),Ud=n(` input through its visual backbone to
obtain a lower-resolution feature map, whose shape is equal to the `),ma=a("code"),Ed=n("image_feature_pool_shape"),zd=n(` attribute of
`),$n=a("a"),Id=n("LayoutLMv2Config"),Cd=n(`. This feature map is then flattened to obtain a sequence of image tokens. As
the size of the feature map is 7x7 by default, one obtains 49 image tokens. These are then concatenated with the text
tokens, and send through the Transformer encoder. This means that the last hidden states of the model will have a
length of 512 + 49 = 561, if you pad the text tokens up to the max length. More generally, the last hidden states
will have a shape of `),ha=a("code"),$d=n("seq_length"),Fd=n(" + "),fa=a("code"),Zd=n("image_feature_pool_shape[0]"),Wd=n(` *
`),ga=a("code"),Rd=n("config.image_feature_pool_shape[1]"),Nd=n("."),qd=d(),oo=a("li"),Bd=n("When calling "),Fn=a("a"),Ad=n("from_pretrained()"),Xd=n(`, a warning will be printed with a long list of
parameter names that are not initialized. This is not a problem, as these parameters are batch normalization
statistics, which are going to have values when fine-tuning on a custom dataset.`),Vd=d(),no=a("li"),Gd=n("If you want to train the model in a distributed environment, make sure to call "),ya=a("code"),Sd=n("synchronize_batch_norm"),Pd=n(` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),ul=d(),Oe=a("p"),Dd=n(`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),Zn=a("a"),Qd=n("LayoutXLM\u2019s documentation page"),Yd=n("."),ml=d(),Ue=a("h2"),He=a("a"),_a=a("span"),g(so.$$.fragment),Od=d(),va=a("span"),Hd=n("Resources"),hl=d(),Wn=a("p"),Kd=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with LayoutLMv2. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),fl=d(),g(ao.$$.fragment),gl=d(),Ke=a("ul"),ro=a("li"),ep=n("A notebook on how to "),lo=a("a"),tp=n("finetune LayoutLMv2 for text-classification on RVL-CDIP dataset"),op=n("."),np=d(),Rn=a("li"),sp=n("See also: "),Nn=a("a"),ap=n("Text classification task guide"),yl=d(),g(io.$$.fragment),_l=d(),ye=a("ul"),co=a("li"),rp=n("A notebook on how to "),po=a("a"),lp=n("finetune LayoutLMv2 for question-answering on DocVQA dataset"),ip=n("."),cp=d(),qn=a("li"),dp=n("See also: "),Bn=a("a"),pp=n("Question answering task guide"),up=d(),An=a("li"),mp=n("See also: "),Xn=a("a"),hp=n("Document question answering task guide"),vl=d(),g(uo.$$.fragment),bl=d(),_e=a("ul"),mo=a("li"),fp=n("A notebook on how to "),ho=a("a"),gp=n("finetune LayoutLMv2 for token-classification on CORD dataset"),yp=n("."),_p=d(),fo=a("li"),vp=n("A notebook on how to "),go=a("a"),bp=n("finetune LayoutLMv2 for token-classification on FUNSD dataset"),Mp=n("."),wp=d(),Vn=a("li"),Lp=n("See also: "),Gn=a("a"),kp=n("Token classification task guide"),Ml=d(),Ee=a("h2"),et=a("a"),ba=a("span"),g(yo.$$.fragment),Tp=d(),Ma=a("span"),xp=n("Usage: LayoutLMv2Processor"),wl=d(),S=a("p"),jp=n("The easiest way to prepare data for the model is to use "),Sn=a("a"),Jp=n("LayoutLMv2Processor"),Up=n(`, which internally
combines a feature extractor (`),Pn=a("a"),Ep=n("LayoutLMv2FeatureExtractor"),zp=n(`) and a tokenizer
(`),Dn=a("a"),Ip=n("LayoutLMv2Tokenizer"),Cp=n(" or "),Qn=a("a"),$p=n("LayoutLMv2TokenizerFast"),Fp=n(`). The feature extractor
handles the image modality, while the tokenizer handles the text modality. A processor combines both, which is ideal
for a multi-modal model like LayoutLMv2. Note that you can still use both separately, if you only want to handle one
modality.`),Ll=d(),g(_o.$$.fragment),kl=d(),J=a("p"),Zp=n("In short, one can provide a document image (and possibly additional data) to "),Yn=a("a"),Wp=n("LayoutLMv2Processor"),Rp=n(`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),On=a("a"),Np=n("LayoutLMv2FeatureExtractor"),qp=n(` to apply OCR on the image to get a list of words and normalized
bounding boxes, as well to resize the image to a given size in order to get the `),wa=a("code"),Bp=n("image"),Ap=n(` input. The words and
normalized bounding boxes are then provided to `),Hn=a("a"),Xp=n("LayoutLMv2Tokenizer"),Vp=n(` or
`),Kn=a("a"),Gp=n("LayoutLMv2TokenizerFast"),Sp=n(", which converts them to token-level "),La=a("code"),Pp=n("input_ids"),Dp=n(`,
`),ka=a("code"),Qp=n("attention_mask"),Yp=n(", "),Ta=a("code"),Op=n("token_type_ids"),Hp=n(", "),xa=a("code"),Kp=n("bbox"),eu=n(`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),ja=a("code"),tu=n("labels"),ou=n("."),Tl=d(),A=a("p"),es=a("a"),nu=n("LayoutLMv2Processor"),su=n(" uses "),vo=a("a"),au=n("PyTesseract"),ru=n(`, a Python
wrapper around Google\u2019s Tesseract OCR engine, under the hood. Note that you can still use your own OCR engine of
choice, and provide the words and normalized boxes yourself. This requires initializing
`),ts=a("a"),lu=n("LayoutLMv2FeatureExtractor"),iu=n(" with "),Ja=a("code"),cu=n("apply_ocr"),du=n(" set to "),Ua=a("code"),pu=n("False"),uu=n("."),xl=d(),os=a("p"),mu=n(`In total, there are 5 use cases that are supported by the processor. Below, we list them all. Note that each of these
use cases work for both batched and non-batched inputs (we illustrate them for non-batched inputs).`),jl=d(),ns=a("p"),Ea=a("strong"),hu=n(`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),Jl=d(),ss=a("p"),fu=n(`This is the simplest case, in which the processor (actually the feature extractor) will perform OCR on the image to get
the words and normalized bounding boxes.`),Ul=d(),g(bo.$$.fragment),El=d(),as=a("p"),za=a("strong"),gu=n("Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),zl=d(),ve=a("p"),yu=n("In case one wants to do OCR themselves, one can initialize the feature extractor with "),Ia=a("code"),_u=n("apply_ocr"),vu=n(` set to
`),Ca=a("code"),bu=n("False"),Mu=n(`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),Il=d(),g(Mo.$$.fragment),Cl=d(),rs=a("p"),$a=a("strong"),wu=n("Use case 3: token classification (training), apply_ocr=False"),$l=d(),P=a("p"),Lu=n(`For token classification tasks (such as FUNSD, CORD, SROIE, Kleister-NDA), one can also provide the corresponding word
labels in order to train a model. The processor will then convert these into token-level `),Fa=a("code"),ku=n("labels"),Tu=n(`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Za=a("code"),xu=n("ignore_index"),ju=n(` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Wa=a("code"),Ju=n("only_label_first_subword"),Uu=n(" set to "),Ra=a("code"),Eu=n("False"),zu=n("."),Fl=d(),g(wo.$$.fragment),Zl=d(),ls=a("p"),Na=a("strong"),Iu=n("Use case 4: visual question answering (inference), apply_ocr=True"),Wl=d(),is=a("p"),Cu=n(`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. By default, the
processor will apply OCR on the image, and create [CLS] question tokens [SEP] word tokens [SEP].`),Rl=d(),g(Lo.$$.fragment),Nl=d(),cs=a("p"),qa=a("strong"),$u=n("Use case 5: visual question answering (inference), apply_ocr=False"),ql=d(),ds=a("p"),Fu=n(`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. If you want to
perform OCR yourself, you can provide your own words and (normalized) bounding boxes to the processor.`),Bl=d(),g(ko.$$.fragment),Al=d(),ze=a("h2"),tt=a("a"),Ba=a("span"),g(To.$$.fragment),Zu=d(),Aa=a("span"),Wu=n("LayoutLMv2Config"),Xl=d(),H=a("div"),g(xo.$$.fragment),Ru=d(),Ie=a("p"),Nu=n("This is the configuration class to store the configuration of a "),ps=a("a"),qu=n("LayoutLMv2Model"),Bu=n(`. It is used to instantiate an
LayoutLMv2 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 LayoutLMv2
`),jo=a("a"),Au=n("microsoft/layoutlmv2-base-uncased"),Xu=n(" architecture."),Vu=d(),Ce=a("p"),Gu=n("Configuration objects inherit from "),us=a("a"),Su=n("PretrainedConfig"),Pu=n(` and can be used to control the model outputs. Read the
documentation from `),ms=a("a"),Du=n("PretrainedConfig"),Qu=n(" for more information."),Yu=d(),g(ot.$$.fragment),Vl=d(),$e=a("h2"),nt=a("a"),Xa=a("span"),g(Jo.$$.fragment),Ou=d(),Va=a("span"),Hu=n("LayoutLMv2FeatureExtractor"),Gl=d(),Fe=a("div"),g(Uo.$$.fragment),Ku=d(),st=a("div"),g(Eo.$$.fragment),em=d(),Ga=a("p"),tm=n("Preprocess an image or a batch of images."),Sl=d(),Ze=a("h2"),at=a("a"),Sa=a("span"),g(zo.$$.fragment),om=d(),Pa=a("span"),nm=n("LayoutLMv2ImageProcessor"),Pl=d(),ce=a("div"),g(Io.$$.fragment),sm=d(),Da=a("p"),am=n("Constructs a LayoutLMv2 image processor."),rm=d(),rt=a("div"),g(Co.$$.fragment),lm=d(),Qa=a("p"),im=n("Preprocess an image or batch of images."),Dl=d(),We=a("h2"),lt=a("a"),Ya=a("span"),g($o.$$.fragment),cm=d(),Oa=a("span"),dm=n("LayoutLMv2Tokenizer"),Ql=d(),N=a("div"),g(Fo.$$.fragment),pm=d(),q=a("p"),um=n("Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),hs=a("a"),mm=n("LayoutLMv2Tokenizer"),hm=n(` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),Ha=a("code"),fm=n("input_ids"),gm=n(", "),Ka=a("code"),ym=n("attention_mask"),_m=n(", "),er=a("code"),vm=n("token_type_ids"),bm=n(", "),tr=a("code"),Mm=n("bbox"),wm=n(`, and
optional `),or=a("code"),Lm=n("labels"),km=n(" (for token classification)."),Tm=d(),Zo=a("p"),xm=n("This tokenizer inherits from "),fs=a("a"),jm=n("PreTrainedTokenizer"),Jm=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Um=d(),gs=a("p"),ys=a("a"),Em=n("LayoutLMv2Tokenizer"),zm=n(` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Im=d(),it=a("div"),g(Wo.$$.fragment),Cm=d(),nr=a("p"),$m=n(`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),Fm=d(),_s=a("div"),g(Ro.$$.fragment),Yl=d(),Re=a("h2"),ct=a("a"),sr=a("span"),g(No.$$.fragment),Zm=d(),ar=a("span"),Wm=n("LayoutLMv2TokenizerFast"),Ol=d(),K=a("div"),g(qo.$$.fragment),Rm=d(),Bo=a("p"),Nm=n("Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),rr=a("em"),qm=n("tokenizers"),Bm=n(" library). Based on WordPiece."),Am=d(),Ao=a("p"),Xm=n("This tokenizer inherits from "),vs=a("a"),Vm=n("PreTrainedTokenizerFast"),Gm=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Sm=d(),dt=a("div"),g(Xo.$$.fragment),Pm=d(),lr=a("p"),Dm=n(`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),Hl=d(),Ne=a("h2"),pt=a("a"),ir=a("span"),g(Vo.$$.fragment),Qm=d(),cr=a("span"),Ym=n("LayoutLMv2Processor"),Kl=d(),X=a("div"),g(Go.$$.fragment),Om=d(),dr=a("p"),Hm=n(`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.`),Km=d(),bs=a("p"),Ms=a("a"),eh=n("LayoutLMv2Processor"),th=n(" offers all the functionalities you need to prepare data for the model."),oh=d(),z=a("p"),nh=n("It first uses "),ws=a("a"),sh=n("LayoutLMv2ImageProcessor"),ah=n(` to resize document images to a fixed size, and optionally applies OCR to
get words and normalized bounding boxes. These are then provided to `),Ls=a("a"),rh=n("LayoutLMv2Tokenizer"),lh=n(` or
`),ks=a("a"),ih=n("LayoutLMv2TokenizerFast"),ch=n(", which turns the words and bounding boxes into token-level "),pr=a("code"),dh=n("input_ids"),ph=n(`,
`),ur=a("code"),uh=n("attention_mask"),mh=n(", "),mr=a("code"),hh=n("token_type_ids"),fh=n(", "),hr=a("code"),gh=n("bbox"),yh=n(". Optionally, one can provide integer "),fr=a("code"),_h=n("word_labels"),vh=n(`, which are turned
into token-level `),gr=a("code"),bh=n("labels"),Mh=n(" for token classification tasks (such as FUNSD, CORD)."),wh=d(),be=a("div"),g(So.$$.fragment),Lh=d(),j=a("p"),kh=n("This method first forwards the "),yr=a("code"),Th=n("images"),xh=n(" argument to "),Po=a("a"),_r=a("strong"),jh=n("call"),Jh=n("()"),Uh=n(`. In case
`),Ts=a("a"),Eh=n("LayoutLMv2ImageProcessor"),zh=n(" was initialized with "),vr=a("code"),Ih=n("apply_ocr"),Ch=n(" set to "),br=a("code"),$h=n("True"),Fh=n(`, it passes the obtained words and
bounding boxes along with the additional arguments to `),Do=a("a"),Mr=a("strong"),Zh=n("call"),Wh=n("()"),Rh=n(` and returns the output,
together with resized `),wr=a("code"),Nh=n("images"),qh=n(". In case "),xs=a("a"),Bh=n("LayoutLMv2ImageProcessor"),Ah=n(" was initialized with "),Lr=a("code"),Xh=n("apply_ocr"),Vh=n(` set to
`),kr=a("code"),Gh=n("False"),Sh=n(", it passes the words ("),Tr=a("code"),Ph=n("text"),Dh=n("/"),xr=a("code"),Qh=n("text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),Yh=n("."),Oh=d(),jr=a("p"),Hh=n("Please refer to the docstring of the above two methods for more information."),ei=d(),qe=a("h2"),ut=a("a"),Jr=a("span"),g(Qo.$$.fragment),Kh=d(),Ur=a("span"),ef=n("LayoutLMv2Model"),ti=d(),de=a("div"),g(Yo.$$.fragment),tf=d(),Oo=a("p"),of=n(`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Ho=a("a"),nf=n("torch.nn.Module"),sf=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),af=d(),ae=a("div"),g(Ko.$$.fragment),rf=d(),Be=a("p"),lf=n("The "),js=a("a"),cf=n("LayoutLMv2Model"),df=n(" forward method, overrides the "),Er=a("code"),pf=n("__call__"),uf=n(" special method."),mf=d(),g(mt.$$.fragment),hf=d(),g(ht.$$.fragment),oi=d(),Ae=a("h2"),ft=a("a"),zr=a("span"),g(en.$$.fragment),ff=d(),Ir=a("span"),gf=n("LayoutLMv2ForSequenceClassification"),ni=d(),ee=a("div"),g(tn.$$.fragment),yf=d(),on=a("p"),_f=n(`LayoutLMv2 Model with a sequence classification head on top (a linear layer on top of the concatenation of the
final hidden state of the [CLS] token, average-pooled initial visual embeddings and average-pooled final visual
embeddings, e.g. for document image classification tasks such as the
`),nn=a("a"),vf=n("RVL-CDIP"),bf=n(" dataset."),Mf=d(),sn=a("p"),wf=n("This model is a PyTorch "),an=a("a"),Lf=n("torch.nn.Module"),kf=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Tf=d(),re=a("div"),g(rn.$$.fragment),xf=d(),Xe=a("p"),jf=n("The "),Js=a("a"),Jf=n("LayoutLMv2ForSequenceClassification"),Uf=n(" forward method, overrides the "),Cr=a("code"),Ef=n("__call__"),zf=n(" special method."),If=d(),g(gt.$$.fragment),Cf=d(),g(yt.$$.fragment),si=d(),Ve=a("h2"),_t=a("a"),$r=a("span"),g(ln.$$.fragment),$f=d(),Fr=a("span"),Ff=n("LayoutLMv2ForTokenClassification"),ai=d(),te=a("div"),g(cn.$$.fragment),Zf=d(),oe=a("p"),Wf=n(`LayoutLMv2 Model with a token classification head on top (a linear layer on top of the text part of the hidden
states) e.g. for sequence labeling (information extraction) tasks such as
`),dn=a("a"),Rf=n("FUNSD"),Nf=n(", "),pn=a("a"),qf=n("SROIE"),Bf=n(`,
`),un=a("a"),Af=n("CORD"),Xf=n(" and "),mn=a("a"),Vf=n("Kleister-NDA"),Gf=n("."),Sf=d(),hn=a("p"),Pf=n("This model is a PyTorch "),fn=a("a"),Df=n("torch.nn.Module"),Qf=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Yf=d(),le=a("div"),g(gn.$$.fragment),Of=d(),Ge=a("p"),Hf=n("The "),Us=a("a"),Kf=n("LayoutLMv2ForTokenClassification"),eg=n(" forward method, overrides the "),Zr=a("code"),tg=n("__call__"),og=n(" special method."),ng=d(),g(vt.$$.fragment),sg=d(),g(bt.$$.fragment),ri=d(),Se=a("h2"),Mt=a("a"),Wr=a("span"),g(yn.$$.fragment),ag=d(),Rr=a("span"),rg=n("LayoutLMv2ForQuestionAnswering"),li=d(),ne=a("div"),g(_n.$$.fragment),lg=d(),pe=a("p"),ig=n(`LayoutLMv2 Model with a span classification head on top for extractive question-answering tasks such as
`),vn=a("a"),cg=n("DocVQA"),dg=n(` (a linear layer on top of the text part of the hidden-states output to
compute `),Nr=a("code"),pg=n("span start logits"),ug=n(" and "),qr=a("code"),mg=n("span end logits"),hg=n(")."),fg=d(),bn=a("p"),gg=n("This model is a PyTorch "),Mn=a("a"),yg=n("torch.nn.Module"),_g=n(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),vg=d(),W=a("div"),g(wn.$$.fragment),bg=d(),Pe=a("p"),Mg=n("The "),Es=a("a"),wg=n("LayoutLMv2ForQuestionAnswering"),Lg=n(" forward method, overrides the "),Br=a("code"),kg=n("__call__"),Tg=n(" special method."),xg=d(),g(wt.$$.fragment),jg=d(),Ar=a("p"),Jg=n("Example:"),Ug=d(),Xr=a("p"),Eg=n(`In this example below, we give the LayoutLMv2 model an image (of texts) and ask it a question. It will give us
a prediction of what it thinks the answer is (the span of the answer within the texts parsed from the image).`),zg=d(),g(Lt.$$.fragment),Ig=d(),g(kt.$$.fragment),this.h()},l(t){const c=kb('[data-svelte="svelte-1phssyn"]',document.head);h=r(c,"META",{name:!0,content:!0}),c.forEach(o),k=p(t),f=r(t,"H1",{class:!0});var Ln=l(f);w=r(Ln,"A",{id:!0,class:!0,href:!0});var Vr=l(w);T=r(Vr,"SPAN",{});var Gr=l(T);y(m.$$.fragment,Gr),Gr.forEach(o),Vr.forEach(o),L=p(Ln),R=r(Ln,"SPAN",{});var Sr=l(R);Di=s(Sr,"LayoutLMV2"),Sr.forEach(o),Ln.forEach(o),Or=p(t),je=r(t,"H2",{class:!0});var kn=l(je);Qe=r(kn,"A",{id:!0,class:!0,href:!0});var Pr=l(Qe);Qs=r(Pr,"SPAN",{});var Dr=l(Qs);y(Ft.$$.fragment,Dr),Dr.forEach(o),Pr.forEach(o),Qi=p(kn),Ys=r(kn,"SPAN",{});var Qr=l(Ys);Yi=s(Qr,"Overview"),Qr.forEach(o),kn.forEach(o),Hr=p(t),me=r(t,"P",{});var De=l(me);Oi=s(De,"The LayoutLMV2 model was proposed in "),Zt=r(De,"A",{href:!0,rel:!0});var Yr=l(Zt);Hi=s(Yr,"LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding"),Yr.forEach(o),Ki=s(De,` by Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu,
Dinei Florencio, Cha Zhang, Wanxiang Che, Min Zhang, Lidong Zhou. LayoutLMV2 improves `),Tn=r(De,"A",{href:!0});var Ag=l(Tn);ec=s(Ag,"LayoutLM"),Ag.forEach(o),tc=s(De,` to obtain
state-of-the-art results across several document image understanding benchmarks:`),De.forEach(o),Kr=p(t),he=r(t,"UL",{});var zs=l(he);O=r(zs,"LI",{});var Me=l(O);oc=s(Me,"information extraction from scanned documents: the "),Wt=r(Me,"A",{href:!0,rel:!0});var Xg=l(Wt);nc=s(Xg,"FUNSD"),Xg.forEach(o),sc=s(Me,` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),Rt=r(Me,"A",{href:!0,rel:!0});var Vg=l(Rt);ac=s(Vg,"CORD"),Vg.forEach(o),rc=s(Me,`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),Nt=r(Me,"A",{href:!0,rel:!0});var Gg=l(Nt);lc=s(Gg,"SROIE"),Gg.forEach(o),ic=s(Me,` dataset (a collection of 626 receipts for training and 347 receipts for testing)
and the `),qt=r(Me,"A",{href:!0,rel:!0});var Sg=l(qt);cc=s(Sg,"Kleister-NDA"),Sg.forEach(o),dc=s(Me,` dataset (a collection of non-disclosure
agreements from the EDGAR database, including 254 documents for training, 83 documents for validation, and 203
documents for testing).`),Me.forEach(o),pc=p(zs),Bt=r(zs,"LI",{});var ci=l(Bt);uc=s(ci,"document image classification: the "),At=r(ci,"A",{href:!0,rel:!0});var Pg=l(At);mc=s(Pg,"RVL-CDIP"),Pg.forEach(o),hc=s(ci,` dataset (a collection of
400,000 images belonging to one of 16 classes).`),ci.forEach(o),fc=p(zs),Xt=r(zs,"LI",{});var di=l(Xt);gc=s(di,"document visual question answering: the "),Vt=r(di,"A",{href:!0,rel:!0});var Dg=l(Vt);yc=s(Dg,"DocVQA"),Dg.forEach(o),_c=s(di,` dataset (a collection of 50,000
questions defined on 12,000+ document images).`),di.forEach(o),zs.forEach(o),el=p(t),xn=r(t,"P",{});var Qg=l(xn);vc=s(Qg,"The abstract from the paper is the following:"),Qg.forEach(o),tl=p(t),jn=r(t,"P",{});var Yg=l(jn);Os=r(Yg,"EM",{});var Og=l(Os);bc=s(Og,`Pre-training of text and layout has proved effective in a variety of visually-rich document understanding tasks due to
its effective model architecture and the advantage of large-scale unlabeled scanned/digital-born documents. In this
paper, we present LayoutLMv2 by pre-training text, layout and image in a multi-modal framework, where new model
architectures and pre-training tasks are leveraged. Specifically, LayoutLMv2 not only uses the existing masked
visual-language modeling task but also the new text-image alignment and text-image matching tasks in the pre-training
stage, where cross-modality interaction is better learned. Meanwhile, it also integrates a spatial-aware self-attention
mechanism into the Transformer architecture, so that the model can fully understand the relative positional
relationship among different text blocks. Experiment results show that LayoutLMv2 outperforms strong baselines and
achieves new state-of-the-art results on a wide variety of downstream visually-rich document understanding tasks,
including FUNSD (0.7895 -> 0.8420), CORD (0.9493 -> 0.9601), SROIE (0.9524 -> 0.9781), Kleister-NDA (0.834 -> 0.852),
RVL-CDIP (0.9443 -> 0.9564), and DocVQA (0.7295 -> 0.8672). The pre-trained LayoutLMv2 model is publicly available at
this https URL.`),Og.forEach(o),Yg.forEach(o),ol=p(t),se=r(t,"P",{});var Tt=l(se);Mc=s(Tt,"LayoutLMv2 depends on "),Hs=r(Tt,"CODE",{});var Hg=l(Hs);wc=s(Hg,"detectron2"),Hg.forEach(o),Lc=s(Tt,", "),Ks=r(Tt,"CODE",{});var Kg=l(Ks);kc=s(Kg,"torchvision"),Kg.forEach(o),Tc=s(Tt," and "),ea=r(Tt,"CODE",{});var ey=l(ea);xc=s(ey,"tesseract"),ey.forEach(o),jc=s(Tt,`. Run the
following to install them:`),Tt.forEach(o),nl=p(t),y(Gt.$$.fragment,t),sl=p(t),Jn=r(t,"P",{});var ty=l(Jn);Jc=s(ty,"(If you are developing for LayoutLMv2, note that passing the doctests also requires the installation of these packages.)"),ty.forEach(o),al=p(t),Un=r(t,"P",{});var oy=l(Un);Uc=s(oy,"Tips:"),oy.forEach(o),rl=p(t),G=r(t,"UL",{});var we=l(G);ta=r(we,"LI",{});var ny=l(ta);Ec=s(ny,`The main difference between LayoutLMv1 and LayoutLMv2 is that the latter incorporates visual embeddings during
pre-training (while LayoutLMv1 only adds visual embeddings during fine-tuning).`),ny.forEach(o),zc=p(we),St=r(we,"LI",{});var pi=l(St);Ic=s(pi,`LayoutLMv2 adds both a relative 1D attention bias as well as a spatial 2D attention bias to the attention scores in
the self-attention layers. Details can be found on page 5 of the `),Pt=r(pi,"A",{href:!0,rel:!0});var sy=l(Pt);Cc=s(sy,"paper"),sy.forEach(o),$c=s(pi,"."),pi.forEach(o),Fc=p(we),Dt=r(we,"LI",{});var ui=l(Dt);Zc=s(ui,"Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),Qt=r(ui,"A",{href:!0,rel:!0});var ay=l(Qt);Wc=s(ay,"here"),ay.forEach(o),Rc=s(ui,"."),ui.forEach(o),Nc=p(we),Je=r(we,"LI",{});var Is=l(Je);qc=s(Is,"LayoutLMv2 uses Facebook AI\u2019s "),Yt=r(Is,"A",{href:!0,rel:!0});var ry=l(Yt);Bc=s(ry,"Detectron2"),ry.forEach(o),Ac=s(Is,` package for its visual
backbone. See `),Ot=r(Is,"A",{href:!0,rel:!0});var ly=l(Ot);Xc=s(ly,"this link"),ly.forEach(o),Vc=s(Is,` for installation
instructions.`),Is.forEach(o),Gc=p(we),x=r(we,"LI",{});var U=l(x);Sc=s(U,"In addition to "),oa=r(U,"CODE",{});var iy=l(oa);Pc=s(iy,"input_ids"),iy.forEach(o),Dc=s(U,", "),En=r(U,"A",{href:!0});var cy=l(En);Qc=s(cy,"forward()"),cy.forEach(o),Yc=s(U,` expects 2 additional inputs, namely
`),na=r(U,"CODE",{});var dy=l(na);Oc=s(dy,"image"),dy.forEach(o),Hc=s(U," and "),sa=r(U,"CODE",{});var py=l(sa);Kc=s(py,"bbox"),py.forEach(o),ed=s(U,". The "),aa=r(U,"CODE",{});var uy=l(aa);td=s(uy,"image"),uy.forEach(o),od=s(U,` input corresponds to the original document image in which the text
tokens occur. The model expects each document image to be of size 224x224. This means that if you have a batch of
document images, `),ra=r(U,"CODE",{});var my=l(ra);nd=s(my,"image"),my.forEach(o),sd=s(U,` should be a tensor of shape (batch_size, 3, 224, 224). This can be either a
`),la=r(U,"CODE",{});var hy=l(la);ad=s(hy,"torch.Tensor"),hy.forEach(o),rd=s(U," or a "),ia=r(U,"CODE",{});var fy=l(ia);ld=s(fy,"Detectron2.structures.ImageList"),fy.forEach(o),id=s(U,`. You don\u2019t need to normalize the channels, as this is
done by the model. Important to note is that the visual backbone expects BGR channels instead of RGB, as all models
in Detectron2 are pre-trained using the BGR format. The `),ca=r(U,"CODE",{});var gy=l(ca);cd=s(gy,"bbox"),gy.forEach(o),dd=s(U,` input are the bounding boxes (i.e. 2D-positions)
of the input text tokens. This is identical to `),zn=r(U,"A",{href:!0});var yy=l(zn);pd=s(yy,"LayoutLMModel"),yy.forEach(o),ud=s(U,`. These can be obtained using an
external OCR engine such as Google\u2019s `),Ht=r(U,"A",{href:!0,rel:!0});var _y=l(Ht);md=s(_y,"Tesseract"),_y.forEach(o),hd=s(U," (there\u2019s a "),Kt=r(U,"A",{href:!0,rel:!0});var vy=l(Kt);fd=s(vy,`Python
wrapper`),vy.forEach(o),gd=s(U,` available). Each bounding box should be in (x0, y0, x1, y1)
format, where (x0, y0) corresponds to the position of the upper left corner in the bounding box, and (x1, y1)
represents the position of the lower right corner. Note that one first needs to normalize the bounding boxes to be on
a 0-1000 scale. To normalize, you can use the following function:`),U.forEach(o),we.forEach(o),ll=p(t),y(eo.$$.fragment,t),il=p(t),fe=r(t,"P",{});var Cs=l(fe);yd=s(Cs,"Here, "),da=r(Cs,"CODE",{});var by=l(da);_d=s(by,"width"),by.forEach(o),vd=s(Cs," and "),pa=r(Cs,"CODE",{});var My=l(pa);bd=s(My,"height"),My.forEach(o),Md=s(Cs,` correspond to the width and height of the original document in which the token
occurs (before resizing the image). Those can be obtained using the Python Image Library (PIL) library for example, as
follows:`),Cs.forEach(o),cl=p(t),y(to.$$.fragment,t),dl=p(t),Ye=r(t,"P",{});var mi=l(Ye);wd=s(mi,"However, this model includes a brand new "),In=r(mi,"A",{href:!0});var wy=l(In);Ld=s(wy,"LayoutLMv2Processor"),wy.forEach(o),kd=s(mi,` which can be used to directly
prepare data for the model (including applying OCR under the hood). More information can be found in the \u201CUsage\u201D
section below.`),mi.forEach(o),pl=p(t),ge=r(t,"UL",{});var $s=l(ge);Z=r($s,"LI",{});var B=l(Z);Td=s(B,"Internally, "),Cn=r(B,"A",{href:!0});var Ly=l(Cn);xd=s(Ly,"LayoutLMv2Model"),Ly.forEach(o),jd=s(B," will send the "),ua=r(B,"CODE",{});var ky=l(ua);Jd=s(ky,"image"),ky.forEach(o),Ud=s(B,` input through its visual backbone to
obtain a lower-resolution feature map, whose shape is equal to the `),ma=r(B,"CODE",{});var Ty=l(ma);Ed=s(Ty,"image_feature_pool_shape"),Ty.forEach(o),zd=s(B,` attribute of
`),$n=r(B,"A",{href:!0});var xy=l($n);Id=s(xy,"LayoutLMv2Config"),xy.forEach(o),Cd=s(B,`. This feature map is then flattened to obtain a sequence of image tokens. As
the size of the feature map is 7x7 by default, one obtains 49 image tokens. These are then concatenated with the text
tokens, and send through the Transformer encoder. This means that the last hidden states of the model will have a
length of 512 + 49 = 561, if you pad the text tokens up to the max length. More generally, the last hidden states
will have a shape of `),ha=r(B,"CODE",{});var jy=l(ha);$d=s(jy,"seq_length"),jy.forEach(o),Fd=s(B," + "),fa=r(B,"CODE",{});var Jy=l(fa);Zd=s(Jy,"image_feature_pool_shape[0]"),Jy.forEach(o),Wd=s(B,` *
`),ga=r(B,"CODE",{});var Uy=l(ga);Rd=s(Uy,"config.image_feature_pool_shape[1]"),Uy.forEach(o),Nd=s(B,"."),B.forEach(o),qd=p($s),oo=r($s,"LI",{});var hi=l(oo);Bd=s(hi,"When calling "),Fn=r(hi,"A",{href:!0});var Ey=l(Fn);Ad=s(Ey,"from_pretrained()"),Ey.forEach(o),Xd=s(hi,`, a warning will be printed with a long list of
parameter names that are not initialized. This is not a problem, as these parameters are batch normalization
statistics, which are going to have values when fine-tuning on a custom dataset.`),hi.forEach(o),Vd=p($s),no=r($s,"LI",{});var fi=l(no);Gd=s(fi,"If you want to train the model in a distributed environment, make sure to call "),ya=r(fi,"CODE",{});var zy=l(ya);Sd=s(zy,"synchronize_batch_norm"),zy.forEach(o),Pd=s(fi,` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),fi.forEach(o),$s.forEach(o),ul=p(t),Oe=r(t,"P",{});var gi=l(Oe);Dd=s(gi,`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),Zn=r(gi,"A",{href:!0});var Iy=l(Zn);Qd=s(Iy,"LayoutXLM\u2019s documentation page"),Iy.forEach(o),Yd=s(gi,"."),gi.forEach(o),ml=p(t),Ue=r(t,"H2",{class:!0});var yi=l(Ue);He=r(yi,"A",{id:!0,class:!0,href:!0});var Cy=l(He);_a=r(Cy,"SPAN",{});var $y=l(_a);y(so.$$.fragment,$y),$y.forEach(o),Cy.forEach(o),Od=p(yi),va=r(yi,"SPAN",{});var Fy=l(va);Hd=s(Fy,"Resources"),Fy.forEach(o),yi.forEach(o),hl=p(t),Wn=r(t,"P",{});var Zy=l(Wn);Kd=s(Zy,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with LayoutLMv2. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Zy.forEach(o),fl=p(t),y(ao.$$.fragment,t),gl=p(t),Ke=r(t,"UL",{});var _i=l(Ke);ro=r(_i,"LI",{});var vi=l(ro);ep=s(vi,"A notebook on how to "),lo=r(vi,"A",{href:!0,rel:!0});var Wy=l(lo);tp=s(Wy,"finetune LayoutLMv2 for text-classification on RVL-CDIP dataset"),Wy.forEach(o),op=s(vi,"."),vi.forEach(o),np=p(_i),Rn=r(_i,"LI",{});var Cg=l(Rn);sp=s(Cg,"See also: "),Nn=r(Cg,"A",{href:!0});var Ry=l(Nn);ap=s(Ry,"Text classification task guide"),Ry.forEach(o),Cg.forEach(o),_i.forEach(o),yl=p(t),y(io.$$.fragment,t),_l=p(t),ye=r(t,"UL",{});var Fs=l(ye);co=r(Fs,"LI",{});var bi=l(co);rp=s(bi,"A notebook on how to "),po=r(bi,"A",{href:!0,rel:!0});var Ny=l(po);lp=s(Ny,"finetune LayoutLMv2 for question-answering on DocVQA dataset"),Ny.forEach(o),ip=s(bi,"."),bi.forEach(o),cp=p(Fs),qn=r(Fs,"LI",{});var $g=l(qn);dp=s($g,"See also: "),Bn=r($g,"A",{href:!0});var qy=l(Bn);pp=s(qy,"Question answering task guide"),qy.forEach(o),$g.forEach(o),up=p(Fs),An=r(Fs,"LI",{});var Fg=l(An);mp=s(Fg,"See also: "),Xn=r(Fg,"A",{href:!0});var By=l(Xn);hp=s(By,"Document question answering task guide"),By.forEach(o),Fg.forEach(o),Fs.forEach(o),vl=p(t),y(uo.$$.fragment,t),bl=p(t),_e=r(t,"UL",{});var Zs=l(_e);mo=r(Zs,"LI",{});var Mi=l(mo);fp=s(Mi,"A notebook on how to "),ho=r(Mi,"A",{href:!0,rel:!0});var Ay=l(ho);gp=s(Ay,"finetune LayoutLMv2 for token-classification on CORD dataset"),Ay.forEach(o),yp=s(Mi,"."),Mi.forEach(o),_p=p(Zs),fo=r(Zs,"LI",{});var wi=l(fo);vp=s(wi,"A notebook on how to "),go=r(wi,"A",{href:!0,rel:!0});var Xy=l(go);bp=s(Xy,"finetune LayoutLMv2 for token-classification on FUNSD dataset"),Xy.forEach(o),Mp=s(wi,"."),wi.forEach(o),wp=p(Zs),Vn=r(Zs,"LI",{});var Zg=l(Vn);Lp=s(Zg,"See also: "),Gn=r(Zg,"A",{href:!0});var Vy=l(Gn);kp=s(Vy,"Token classification task guide"),Vy.forEach(o),Zg.forEach(o),Zs.forEach(o),Ml=p(t),Ee=r(t,"H2",{class:!0});var Li=l(Ee);et=r(Li,"A",{id:!0,class:!0,href:!0});var Gy=l(et);ba=r(Gy,"SPAN",{});var Sy=l(ba);y(yo.$$.fragment,Sy),Sy.forEach(o),Gy.forEach(o),Tp=p(Li),Ma=r(Li,"SPAN",{});var Py=l(Ma);xp=s(Py,"Usage: LayoutLMv2Processor"),Py.forEach(o),Li.forEach(o),wl=p(t),S=r(t,"P",{});var Le=l(S);jp=s(Le,"The easiest way to prepare data for the model is to use "),Sn=r(Le,"A",{href:!0});var Dy=l(Sn);Jp=s(Dy,"LayoutLMv2Processor"),Dy.forEach(o),Up=s(Le,`, which internally
combines a feature extractor (`),Pn=r(Le,"A",{href:!0});var Qy=l(Pn);Ep=s(Qy,"LayoutLMv2FeatureExtractor"),Qy.forEach(o),zp=s(Le,`) and a tokenizer
(`),Dn=r(Le,"A",{href:!0});var Yy=l(Dn);Ip=s(Yy,"LayoutLMv2Tokenizer"),Yy.forEach(o),Cp=s(Le," or "),Qn=r(Le,"A",{href:!0});var Oy=l(Qn);$p=s(Oy,"LayoutLMv2TokenizerFast"),Oy.forEach(o),Fp=s(Le,`). The feature extractor
handles the image modality, while the tokenizer handles the text modality. A processor combines both, which is ideal
for a multi-modal model like LayoutLMv2. Note that you can still use both separately, if you only want to handle one
modality.`),Le.forEach(o),Ll=p(t),y(_o.$$.fragment,t),kl=p(t),J=r(t,"P",{});var C=l(J);Zp=s(C,"In short, one can provide a document image (and possibly additional data) to "),Yn=r(C,"A",{href:!0});var Hy=l(Yn);Wp=s(Hy,"LayoutLMv2Processor"),Hy.forEach(o),Rp=s(C,`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),On=r(C,"A",{href:!0});var Ky=l(On);Np=s(Ky,"LayoutLMv2FeatureExtractor"),Ky.forEach(o),qp=s(C,` to apply OCR on the image to get a list of words and normalized
bounding boxes, as well to resize the image to a given size in order to get the `),wa=r(C,"CODE",{});var e_=l(wa);Bp=s(e_,"image"),e_.forEach(o),Ap=s(C,` input. The words and
normalized bounding boxes are then provided to `),Hn=r(C,"A",{href:!0});var t_=l(Hn);Xp=s(t_,"LayoutLMv2Tokenizer"),t_.forEach(o),Vp=s(C,` or
`),Kn=r(C,"A",{href:!0});var o_=l(Kn);Gp=s(o_,"LayoutLMv2TokenizerFast"),o_.forEach(o),Sp=s(C,", which converts them to token-level "),La=r(C,"CODE",{});var n_=l(La);Pp=s(n_,"input_ids"),n_.forEach(o),Dp=s(C,`,
`),ka=r(C,"CODE",{});var s_=l(ka);Qp=s(s_,"attention_mask"),s_.forEach(o),Yp=s(C,", "),Ta=r(C,"CODE",{});var a_=l(Ta);Op=s(a_,"token_type_ids"),a_.forEach(o),Hp=s(C,", "),xa=r(C,"CODE",{});var r_=l(xa);Kp=s(r_,"bbox"),r_.forEach(o),eu=s(C,`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),ja=r(C,"CODE",{});var l_=l(ja);tu=s(l_,"labels"),l_.forEach(o),ou=s(C,"."),C.forEach(o),Tl=p(t),A=r(t,"P",{});var ue=l(A);es=r(ue,"A",{href:!0});var i_=l(es);nu=s(i_,"LayoutLMv2Processor"),i_.forEach(o),su=s(ue," uses "),vo=r(ue,"A",{href:!0,rel:!0});var c_=l(vo);au=s(c_,"PyTesseract"),c_.forEach(o),ru=s(ue,`, a Python
wrapper around Google\u2019s Tesseract OCR engine, under the hood. Note that you can still use your own OCR engine of
choice, and provide the words and normalized boxes yourself. This requires initializing
`),ts=r(ue,"A",{href:!0});var d_=l(ts);lu=s(d_,"LayoutLMv2FeatureExtractor"),d_.forEach(o),iu=s(ue," with "),Ja=r(ue,"CODE",{});var p_=l(Ja);cu=s(p_,"apply_ocr"),p_.forEach(o),du=s(ue," set to "),Ua=r(ue,"CODE",{});var u_=l(Ua);pu=s(u_,"False"),u_.forEach(o),uu=s(ue,"."),ue.forEach(o),xl=p(t),os=r(t,"P",{});var m_=l(os);mu=s(m_,`In total, there are 5 use cases that are supported by the processor. Below, we list them all. Note that each of these
use cases work for both batched and non-batched inputs (we illustrate them for non-batched inputs).`),m_.forEach(o),jl=p(t),ns=r(t,"P",{});var h_=l(ns);Ea=r(h_,"STRONG",{});var f_=l(Ea);hu=s(f_,`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),f_.forEach(o),h_.forEach(o),Jl=p(t),ss=r(t,"P",{});var g_=l(ss);fu=s(g_,`This is the simplest case, in which the processor (actually the feature extractor) will perform OCR on the image to get
the words and normalized bounding boxes.`),g_.forEach(o),Ul=p(t),y(bo.$$.fragment,t),El=p(t),as=r(t,"P",{});var y_=l(as);za=r(y_,"STRONG",{});var __=l(za);gu=s(__,"Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),__.forEach(o),y_.forEach(o),zl=p(t),ve=r(t,"P",{});var Ws=l(ve);yu=s(Ws,"In case one wants to do OCR themselves, one can initialize the feature extractor with "),Ia=r(Ws,"CODE",{});var v_=l(Ia);_u=s(v_,"apply_ocr"),v_.forEach(o),vu=s(Ws,` set to
`),Ca=r(Ws,"CODE",{});var b_=l(Ca);bu=s(b_,"False"),b_.forEach(o),Mu=s(Ws,`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),Ws.forEach(o),Il=p(t),y(Mo.$$.fragment,t),Cl=p(t),rs=r(t,"P",{});var M_=l(rs);$a=r(M_,"STRONG",{});var w_=l($a);wu=s(w_,"Use case 3: token classification (training), apply_ocr=False"),w_.forEach(o),M_.forEach(o),$l=p(t),P=r(t,"P",{});var ke=l(P);Lu=s(ke,`For token classification tasks (such as FUNSD, CORD, SROIE, Kleister-NDA), one can also provide the corresponding word
labels in order to train a model. The processor will then convert these into token-level `),Fa=r(ke,"CODE",{});var L_=l(Fa);ku=s(L_,"labels"),L_.forEach(o),Tu=s(ke,`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Za=r(ke,"CODE",{});var k_=l(Za);xu=s(k_,"ignore_index"),k_.forEach(o),ju=s(ke,` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Wa=r(ke,"CODE",{});var T_=l(Wa);Ju=s(T_,"only_label_first_subword"),T_.forEach(o),Uu=s(ke," set to "),Ra=r(ke,"CODE",{});var x_=l(Ra);Eu=s(x_,"False"),x_.forEach(o),zu=s(ke,"."),ke.forEach(o),Fl=p(t),y(wo.$$.fragment,t),Zl=p(t),ls=r(t,"P",{});var j_=l(ls);Na=r(j_,"STRONG",{});var J_=l(Na);Iu=s(J_,"Use case 4: visual question answering (inference), apply_ocr=True"),J_.forEach(o),j_.forEach(o),Wl=p(t),is=r(t,"P",{});var U_=l(is);Cu=s(U_,`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. By default, the
processor will apply OCR on the image, and create [CLS] question tokens [SEP] word tokens [SEP].`),U_.forEach(o),Rl=p(t),y(Lo.$$.fragment,t),Nl=p(t),cs=r(t,"P",{});var E_=l(cs);qa=r(E_,"STRONG",{});var z_=l(qa);$u=s(z_,"Use case 5: visual question answering (inference), apply_ocr=False"),z_.forEach(o),E_.forEach(o),ql=p(t),ds=r(t,"P",{});var I_=l(ds);Fu=s(I_,`For visual question answering tasks (such as DocVQA), you can provide a question to the processor. If you want to
perform OCR yourself, you can provide your own words and (normalized) bounding boxes to the processor.`),I_.forEach(o),Bl=p(t),y(ko.$$.fragment,t),Al=p(t),ze=r(t,"H2",{class:!0});var ki=l(ze);tt=r(ki,"A",{id:!0,class:!0,href:!0});var C_=l(tt);Ba=r(C_,"SPAN",{});var $_=l(Ba);y(To.$$.fragment,$_),$_.forEach(o),C_.forEach(o),Zu=p(ki),Aa=r(ki,"SPAN",{});var F_=l(Aa);Wu=s(F_,"LayoutLMv2Config"),F_.forEach(o),ki.forEach(o),Xl=p(t),H=r(t,"DIV",{class:!0});var xt=l(H);y(xo.$$.fragment,xt),Ru=p(xt),Ie=r(xt,"P",{});var Rs=l(Ie);Nu=s(Rs,"This is the configuration class to store the configuration of a "),ps=r(Rs,"A",{href:!0});var Z_=l(ps);qu=s(Z_,"LayoutLMv2Model"),Z_.forEach(o),Bu=s(Rs,`. It is used to instantiate an
LayoutLMv2 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 LayoutLMv2
`),jo=r(Rs,"A",{href:!0,rel:!0});var W_=l(jo);Au=s(W_,"microsoft/layoutlmv2-base-uncased"),W_.forEach(o),Xu=s(Rs," architecture."),Rs.forEach(o),Vu=p(xt),Ce=r(xt,"P",{});var Ns=l(Ce);Gu=s(Ns,"Configuration objects inherit from "),us=r(Ns,"A",{href:!0});var R_=l(us);Su=s(R_,"PretrainedConfig"),R_.forEach(o),Pu=s(Ns,` and can be used to control the model outputs. Read the
documentation from `),ms=r(Ns,"A",{href:!0});var N_=l(ms);Du=s(N_,"PretrainedConfig"),N_.forEach(o),Qu=s(Ns," for more information."),Ns.forEach(o),Yu=p(xt),y(ot.$$.fragment,xt),xt.forEach(o),Vl=p(t),$e=r(t,"H2",{class:!0});var Ti=l($e);nt=r(Ti,"A",{id:!0,class:!0,href:!0});var q_=l(nt);Xa=r(q_,"SPAN",{});var B_=l(Xa);y(Jo.$$.fragment,B_),B_.forEach(o),q_.forEach(o),Ou=p(Ti),Va=r(Ti,"SPAN",{});var A_=l(Va);Hu=s(A_,"LayoutLMv2FeatureExtractor"),A_.forEach(o),Ti.forEach(o),Gl=p(t),Fe=r(t,"DIV",{class:!0});var xi=l(Fe);y(Uo.$$.fragment,xi),Ku=p(xi),st=r(xi,"DIV",{class:!0});var ji=l(st);y(Eo.$$.fragment,ji),em=p(ji),Ga=r(ji,"P",{});var X_=l(Ga);tm=s(X_,"Preprocess an image or a batch of images."),X_.forEach(o),ji.forEach(o),xi.forEach(o),Sl=p(t),Ze=r(t,"H2",{class:!0});var Ji=l(Ze);at=r(Ji,"A",{id:!0,class:!0,href:!0});var V_=l(at);Sa=r(V_,"SPAN",{});var G_=l(Sa);y(zo.$$.fragment,G_),G_.forEach(o),V_.forEach(o),om=p(Ji),Pa=r(Ji,"SPAN",{});var S_=l(Pa);nm=s(S_,"LayoutLMv2ImageProcessor"),S_.forEach(o),Ji.forEach(o),Pl=p(t),ce=r(t,"DIV",{class:!0});var qs=l(ce);y(Io.$$.fragment,qs),sm=p(qs),Da=r(qs,"P",{});var P_=l(Da);am=s(P_,"Constructs a LayoutLMv2 image processor."),P_.forEach(o),rm=p(qs),rt=r(qs,"DIV",{class:!0});var Ui=l(rt);y(Co.$$.fragment,Ui),lm=p(Ui),Qa=r(Ui,"P",{});var D_=l(Qa);im=s(D_,"Preprocess an image or batch of images."),D_.forEach(o),Ui.forEach(o),qs.forEach(o),Dl=p(t),We=r(t,"H2",{class:!0});var Ei=l(We);lt=r(Ei,"A",{id:!0,class:!0,href:!0});var Q_=l(lt);Ya=r(Q_,"SPAN",{});var Y_=l(Ya);y($o.$$.fragment,Y_),Y_.forEach(o),Q_.forEach(o),cm=p(Ei),Oa=r(Ei,"SPAN",{});var O_=l(Oa);dm=s(O_,"LayoutLMv2Tokenizer"),O_.forEach(o),Ei.forEach(o),Ql=p(t),N=r(t,"DIV",{class:!0});var ie=l(N);y(Fo.$$.fragment,ie),pm=p(ie),q=r(ie,"P",{});var D=l(q);um=s(D,"Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),hs=r(D,"A",{href:!0});var H_=l(hs);mm=s(H_,"LayoutLMv2Tokenizer"),H_.forEach(o),hm=s(D,` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),Ha=r(D,"CODE",{});var K_=l(Ha);fm=s(K_,"input_ids"),K_.forEach(o),gm=s(D,", "),Ka=r(D,"CODE",{});var ev=l(Ka);ym=s(ev,"attention_mask"),ev.forEach(o),_m=s(D,", "),er=r(D,"CODE",{});var tv=l(er);vm=s(tv,"token_type_ids"),tv.forEach(o),bm=s(D,", "),tr=r(D,"CODE",{});var ov=l(tr);Mm=s(ov,"bbox"),ov.forEach(o),wm=s(D,`, and
optional `),or=r(D,"CODE",{});var nv=l(or);Lm=s(nv,"labels"),nv.forEach(o),km=s(D," (for token classification)."),D.forEach(o),Tm=p(ie),Zo=r(ie,"P",{});var zi=l(Zo);xm=s(zi,"This tokenizer inherits from "),fs=r(zi,"A",{href:!0});var sv=l(fs);jm=s(sv,"PreTrainedTokenizer"),sv.forEach(o),Jm=s(zi,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),zi.forEach(o),Um=p(ie),gs=r(ie,"P",{});var Wg=l(gs);ys=r(Wg,"A",{href:!0});var av=l(ys);Em=s(av,"LayoutLMv2Tokenizer"),av.forEach(o),zm=s(Wg,` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Wg.forEach(o),Im=p(ie),it=r(ie,"DIV",{class:!0});var Ii=l(it);y(Wo.$$.fragment,Ii),Cm=p(Ii),nr=r(Ii,"P",{});var rv=l(nr);$m=s(rv,`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),rv.forEach(o),Ii.forEach(o),Fm=p(ie),_s=r(ie,"DIV",{class:!0});var lv=l(_s);y(Ro.$$.fragment,lv),lv.forEach(o),ie.forEach(o),Yl=p(t),Re=r(t,"H2",{class:!0});var Ci=l(Re);ct=r(Ci,"A",{id:!0,class:!0,href:!0});var iv=l(ct);sr=r(iv,"SPAN",{});var cv=l(sr);y(No.$$.fragment,cv),cv.forEach(o),iv.forEach(o),Zm=p(Ci),ar=r(Ci,"SPAN",{});var dv=l(ar);Wm=s(dv,"LayoutLMv2TokenizerFast"),dv.forEach(o),Ci.forEach(o),Ol=p(t),K=r(t,"DIV",{class:!0});var jt=l(K);y(qo.$$.fragment,jt),Rm=p(jt),Bo=r(jt,"P",{});var $i=l(Bo);Nm=s($i,"Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),rr=r($i,"EM",{});var pv=l(rr);qm=s(pv,"tokenizers"),pv.forEach(o),Bm=s($i," library). Based on WordPiece."),$i.forEach(o),Am=p(jt),Ao=r(jt,"P",{});var Fi=l(Ao);Xm=s(Fi,"This tokenizer inherits from "),vs=r(Fi,"A",{href:!0});var uv=l(vs);Vm=s(uv,"PreTrainedTokenizerFast"),uv.forEach(o),Gm=s(Fi,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Fi.forEach(o),Sm=p(jt),dt=r(jt,"DIV",{class:!0});var Zi=l(dt);y(Xo.$$.fragment,Zi),Pm=p(Zi),lr=r(Zi,"P",{});var mv=l(lr);Dm=s(mv,`Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences with word-level normalized bounding boxes and optional labels.`),mv.forEach(o),Zi.forEach(o),jt.forEach(o),Hl=p(t),Ne=r(t,"H2",{class:!0});var Wi=l(Ne);pt=r(Wi,"A",{id:!0,class:!0,href:!0});var hv=l(pt);ir=r(hv,"SPAN",{});var fv=l(ir);y(Vo.$$.fragment,fv),fv.forEach(o),hv.forEach(o),Qm=p(Wi),cr=r(Wi,"SPAN",{});var gv=l(cr);Ym=s(gv,"LayoutLMv2Processor"),gv.forEach(o),Wi.forEach(o),Kl=p(t),X=r(t,"DIV",{class:!0});var Te=l(X);y(Go.$$.fragment,Te),Om=p(Te),dr=r(Te,"P",{});var yv=l(dr);Hm=s(yv,`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.`),yv.forEach(o),Km=p(Te),bs=r(Te,"P",{});var Rg=l(bs);Ms=r(Rg,"A",{href:!0});var _v=l(Ms);eh=s(_v,"LayoutLMv2Processor"),_v.forEach(o),th=s(Rg," offers all the functionalities you need to prepare data for the model."),Rg.forEach(o),oh=p(Te),z=r(Te,"P",{});var $=l(z);nh=s($,"It first uses "),ws=r($,"A",{href:!0});var vv=l(ws);sh=s(vv,"LayoutLMv2ImageProcessor"),vv.forEach(o),ah=s($,` to resize document images to a fixed size, and optionally applies OCR to
get words and normalized bounding boxes. These are then provided to `),Ls=r($,"A",{href:!0});var bv=l(Ls);rh=s(bv,"LayoutLMv2Tokenizer"),bv.forEach(o),lh=s($,` or
`),ks=r($,"A",{href:!0});var Mv=l(ks);ih=s(Mv,"LayoutLMv2TokenizerFast"),Mv.forEach(o),ch=s($,", which turns the words and bounding boxes into token-level "),pr=r($,"CODE",{});var wv=l(pr);dh=s(wv,"input_ids"),wv.forEach(o),ph=s($,`,
`),ur=r($,"CODE",{});var Lv=l(ur);uh=s(Lv,"attention_mask"),Lv.forEach(o),mh=s($,", "),mr=r($,"CODE",{});var kv=l(mr);hh=s(kv,"token_type_ids"),kv.forEach(o),fh=s($,", "),hr=r($,"CODE",{});var Tv=l(hr);gh=s(Tv,"bbox"),Tv.forEach(o),yh=s($,". Optionally, one can provide integer "),fr=r($,"CODE",{});var xv=l(fr);_h=s(xv,"word_labels"),xv.forEach(o),vh=s($,`, which are turned
into token-level `),gr=r($,"CODE",{});var jv=l(gr);bh=s(jv,"labels"),jv.forEach(o),Mh=s($," for token classification tasks (such as FUNSD, CORD)."),$.forEach(o),wh=p(Te),be=r(Te,"DIV",{class:!0});var Bs=l(be);y(So.$$.fragment,Bs),Lh=p(Bs),j=r(Bs,"P",{});var E=l(j);kh=s(E,"This method first forwards the "),yr=r(E,"CODE",{});var Jv=l(yr);Th=s(Jv,"images"),Jv.forEach(o),xh=s(E," argument to "),Po=r(E,"A",{href:!0});var Ng=l(Po);_r=r(Ng,"STRONG",{});var Uv=l(_r);jh=s(Uv,"call"),Uv.forEach(o),Jh=s(Ng,"()"),Ng.forEach(o),Uh=s(E,`. In case
`),Ts=r(E,"A",{href:!0});var Ev=l(Ts);Eh=s(Ev,"LayoutLMv2ImageProcessor"),Ev.forEach(o),zh=s(E," was initialized with "),vr=r(E,"CODE",{});var zv=l(vr);Ih=s(zv,"apply_ocr"),zv.forEach(o),Ch=s(E," set to "),br=r(E,"CODE",{});var Iv=l(br);$h=s(Iv,"True"),Iv.forEach(o),Fh=s(E,`, it passes the obtained words and
bounding boxes along with the additional arguments to `),Do=r(E,"A",{href:!0});var qg=l(Do);Mr=r(qg,"STRONG",{});var Cv=l(Mr);Zh=s(Cv,"call"),Cv.forEach(o),Wh=s(qg,"()"),qg.forEach(o),Rh=s(E,` and returns the output,
together with resized `),wr=r(E,"CODE",{});var $v=l(wr);Nh=s($v,"images"),$v.forEach(o),qh=s(E,". In case "),xs=r(E,"A",{href:!0});var Fv=l(xs);Bh=s(Fv,"LayoutLMv2ImageProcessor"),Fv.forEach(o),Ah=s(E," was initialized with "),Lr=r(E,"CODE",{});var Zv=l(Lr);Xh=s(Zv,"apply_ocr"),Zv.forEach(o),Vh=s(E,` set to
`),kr=r(E,"CODE",{});var Wv=l(kr);Gh=s(Wv,"False"),Wv.forEach(o),Sh=s(E,", it passes the words ("),Tr=r(E,"CODE",{});var Rv=l(Tr);Ph=s(Rv,"text"),Rv.forEach(o),Dh=s(E,"/"),xr=r(E,"CODE",{});var Nv=l(xr);Qh=s(Nv,"text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),Nv.forEach(o),Yh=s(E,"."),E.forEach(o),Oh=p(Bs),jr=r(Bs,"P",{});var qv=l(jr);Hh=s(qv,"Please refer to the docstring of the above two methods for more information."),qv.forEach(o),Bs.forEach(o),Te.forEach(o),ei=p(t),qe=r(t,"H2",{class:!0});var Ri=l(qe);ut=r(Ri,"A",{id:!0,class:!0,href:!0});var Bv=l(ut);Jr=r(Bv,"SPAN",{});var Av=l(Jr);y(Qo.$$.fragment,Av),Av.forEach(o),Bv.forEach(o),Kh=p(Ri),Ur=r(Ri,"SPAN",{});var Xv=l(Ur);ef=s(Xv,"LayoutLMv2Model"),Xv.forEach(o),Ri.forEach(o),ti=p(t),de=r(t,"DIV",{class:!0});var As=l(de);y(Yo.$$.fragment,As),tf=p(As),Oo=r(As,"P",{});var Ni=l(Oo);of=s(Ni,`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Ho=r(Ni,"A",{href:!0,rel:!0});var Vv=l(Ho);nf=s(Vv,"torch.nn.Module"),Vv.forEach(o),sf=s(Ni,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ni.forEach(o),af=p(As),ae=r(As,"DIV",{class:!0});var Jt=l(ae);y(Ko.$$.fragment,Jt),rf=p(Jt),Be=r(Jt,"P",{});var Xs=l(Be);lf=s(Xs,"The "),js=r(Xs,"A",{href:!0});var Gv=l(js);cf=s(Gv,"LayoutLMv2Model"),Gv.forEach(o),df=s(Xs," forward method, overrides the "),Er=r(Xs,"CODE",{});var Sv=l(Er);pf=s(Sv,"__call__"),Sv.forEach(o),uf=s(Xs," special method."),Xs.forEach(o),mf=p(Jt),y(mt.$$.fragment,Jt),hf=p(Jt),y(ht.$$.fragment,Jt),Jt.forEach(o),As.forEach(o),oi=p(t),Ae=r(t,"H2",{class:!0});var qi=l(Ae);ft=r(qi,"A",{id:!0,class:!0,href:!0});var Pv=l(ft);zr=r(Pv,"SPAN",{});var Dv=l(zr);y(en.$$.fragment,Dv),Dv.forEach(o),Pv.forEach(o),ff=p(qi),Ir=r(qi,"SPAN",{});var Qv=l(Ir);gf=s(Qv,"LayoutLMv2ForSequenceClassification"),Qv.forEach(o),qi.forEach(o),ni=p(t),ee=r(t,"DIV",{class:!0});var Ut=l(ee);y(tn.$$.fragment,Ut),yf=p(Ut),on=r(Ut,"P",{});var Bi=l(on);_f=s(Bi,`LayoutLMv2 Model with a sequence classification head on top (a linear layer on top of the concatenation of the
final hidden state of the [CLS] token, average-pooled initial visual embeddings and average-pooled final visual
embeddings, e.g. for document image classification tasks such as the
`),nn=r(Bi,"A",{href:!0,rel:!0});var Yv=l(nn);vf=s(Yv,"RVL-CDIP"),Yv.forEach(o),bf=s(Bi," dataset."),Bi.forEach(o),Mf=p(Ut),sn=r(Ut,"P",{});var Ai=l(sn);wf=s(Ai,"This model is a PyTorch "),an=r(Ai,"A",{href:!0,rel:!0});var Ov=l(an);Lf=s(Ov,"torch.nn.Module"),Ov.forEach(o),kf=s(Ai,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ai.forEach(o),Tf=p(Ut),re=r(Ut,"DIV",{class:!0});var Et=l(re);y(rn.$$.fragment,Et),xf=p(Et),Xe=r(Et,"P",{});var Vs=l(Xe);jf=s(Vs,"The "),Js=r(Vs,"A",{href:!0});var Hv=l(Js);Jf=s(Hv,"LayoutLMv2ForSequenceClassification"),Hv.forEach(o),Uf=s(Vs," forward method, overrides the "),Cr=r(Vs,"CODE",{});var Kv=l(Cr);Ef=s(Kv,"__call__"),Kv.forEach(o),zf=s(Vs," special method."),Vs.forEach(o),If=p(Et),y(gt.$$.fragment,Et),Cf=p(Et),y(yt.$$.fragment,Et),Et.forEach(o),Ut.forEach(o),si=p(t),Ve=r(t,"H2",{class:!0});var Xi=l(Ve);_t=r(Xi,"A",{id:!0,class:!0,href:!0});var eb=l(_t);$r=r(eb,"SPAN",{});var tb=l($r);y(ln.$$.fragment,tb),tb.forEach(o),eb.forEach(o),$f=p(Xi),Fr=r(Xi,"SPAN",{});var ob=l(Fr);Ff=s(ob,"LayoutLMv2ForTokenClassification"),ob.forEach(o),Xi.forEach(o),ai=p(t),te=r(t,"DIV",{class:!0});var zt=l(te);y(cn.$$.fragment,zt),Zf=p(zt),oe=r(zt,"P",{});var xe=l(oe);Wf=s(xe,`LayoutLMv2 Model with a token classification head on top (a linear layer on top of the text part of the hidden
states) e.g. for sequence labeling (information extraction) tasks such as
`),dn=r(xe,"A",{href:!0,rel:!0});var nb=l(dn);Rf=s(nb,"FUNSD"),nb.forEach(o),Nf=s(xe,", "),pn=r(xe,"A",{href:!0,rel:!0});var sb=l(pn);qf=s(sb,"SROIE"),sb.forEach(o),Bf=s(xe,`,
`),un=r(xe,"A",{href:!0,rel:!0});var ab=l(un);Af=s(ab,"CORD"),ab.forEach(o),Xf=s(xe," and "),mn=r(xe,"A",{href:!0,rel:!0});var rb=l(mn);Vf=s(rb,"Kleister-NDA"),rb.forEach(o),Gf=s(xe,"."),xe.forEach(o),Sf=p(zt),hn=r(zt,"P",{});var Vi=l(hn);Pf=s(Vi,"This model is a PyTorch "),fn=r(Vi,"A",{href:!0,rel:!0});var lb=l(fn);Df=s(lb,"torch.nn.Module"),lb.forEach(o),Qf=s(Vi,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Vi.forEach(o),Yf=p(zt),le=r(zt,"DIV",{class:!0});var It=l(le);y(gn.$$.fragment,It),Of=p(It),Ge=r(It,"P",{});var Gs=l(Ge);Hf=s(Gs,"The "),Us=r(Gs,"A",{href:!0});var ib=l(Us);Kf=s(ib,"LayoutLMv2ForTokenClassification"),ib.forEach(o),eg=s(Gs," forward method, overrides the "),Zr=r(Gs,"CODE",{});var cb=l(Zr);tg=s(cb,"__call__"),cb.forEach(o),og=s(Gs," special method."),Gs.forEach(o),ng=p(It),y(vt.$$.fragment,It),sg=p(It),y(bt.$$.fragment,It),It.forEach(o),zt.forEach(o),ri=p(t),Se=r(t,"H2",{class:!0});var Gi=l(Se);Mt=r(Gi,"A",{id:!0,class:!0,href:!0});var db=l(Mt);Wr=r(db,"SPAN",{});var pb=l(Wr);y(yn.$$.fragment,pb),pb.forEach(o),db.forEach(o),ag=p(Gi),Rr=r(Gi,"SPAN",{});var ub=l(Rr);rg=s(ub,"LayoutLMv2ForQuestionAnswering"),ub.forEach(o),Gi.forEach(o),li=p(t),ne=r(t,"DIV",{class:!0});var Ct=l(ne);y(_n.$$.fragment,Ct),lg=p(Ct),pe=r(Ct,"P",{});var $t=l(pe);ig=s($t,`LayoutLMv2 Model with a span classification head on top for extractive question-answering tasks such as
`),vn=r($t,"A",{href:!0,rel:!0});var mb=l(vn);cg=s(mb,"DocVQA"),mb.forEach(o),dg=s($t,` (a linear layer on top of the text part of the hidden-states output to
compute `),Nr=r($t,"CODE",{});var hb=l(Nr);pg=s(hb,"span start logits"),hb.forEach(o),ug=s($t," and "),qr=r($t,"CODE",{});var fb=l(qr);mg=s(fb,"span end logits"),fb.forEach(o),hg=s($t,")."),$t.forEach(o),fg=p(Ct),bn=r(Ct,"P",{});var Si=l(bn);gg=s(Si,"This model is a PyTorch "),Mn=r(Si,"A",{href:!0,rel:!0});var gb=l(Mn);yg=s(gb,"torch.nn.Module"),gb.forEach(o),_g=s(Si,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Si.forEach(o),vg=p(Ct),W=r(Ct,"DIV",{class:!0});var Q=l(W);y(wn.$$.fragment,Q),bg=p(Q),Pe=r(Q,"P",{});var Ss=l(Pe);Mg=s(Ss,"The "),Es=r(Ss,"A",{href:!0});var yb=l(Es);wg=s(yb,"LayoutLMv2ForQuestionAnswering"),yb.forEach(o),Lg=s(Ss," forward method, overrides the "),Br=r(Ss,"CODE",{});var _b=l(Br);kg=s(_b,"__call__"),_b.forEach(o),Tg=s(Ss," special method."),Ss.forEach(o),xg=p(Q),y(wt.$$.fragment,Q),jg=p(Q),Ar=r(Q,"P",{});var vb=l(Ar);Jg=s(vb,"Example:"),vb.forEach(o),Ug=p(Q),Xr=r(Q,"P",{});var bb=l(Xr);Eg=s(bb,`In this example below, we give the LayoutLMv2 model an image (of texts) and ask it a question. It will give us
a prediction of what it thinks the answer is (the span of the answer within the texts parsed from the image).`),bb.forEach(o),zg=p(Q),y(Lt.$$.fragment,Q),Ig=p(Q),y(kt.$$.fragment,Q),Q.forEach(o),Ct.forEach(o),this.h()},h(){i(h,"name","hf:doc:metadata"),i(h,"content",JSON.stringify(Wb)),i(w,"id","layoutlmv2"),i(w,"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"),i(w,"href","#layoutlmv2"),i(f,"class","relative group"),i(Qe,"id","overview"),i(Qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Qe,"href","#overview"),i(je,"class","relative group"),i(Zt,"href","https://arxiv.org/abs/2012.14740"),i(Zt,"rel","nofollow"),i(Tn,"href","layoutlm"),i(Wt,"href","https://guillaumejaume.github.io/FUNSD/"),i(Wt,"rel","nofollow"),i(Rt,"href","https://github.com/clovaai/cord"),i(Rt,"rel","nofollow"),i(Nt,"href","https://rrc.cvc.uab.es/?ch=13"),i(Nt,"rel","nofollow"),i(qt,"href","https://github.com/applicaai/kleister-nda"),i(qt,"rel","nofollow"),i(At,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),i(At,"rel","nofollow"),i(Vt,"href","https://arxiv.org/abs/2007.00398"),i(Vt,"rel","nofollow"),i(Pt,"href","https://arxiv.org/abs/2012.14740"),i(Pt,"rel","nofollow"),i(Qt,"href","https://github.com/NielsRogge/Transformers-Tutorials"),i(Qt,"rel","nofollow"),i(Yt,"href","https://github.com/facebookresearch/detectron2/"),i(Yt,"rel","nofollow"),i(Ot,"href","https://detectron2.readthedocs.io/en/latest/tutorials/install.html"),i(Ot,"rel","nofollow"),i(En,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model.forward"),i(zn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlm#transformers.LayoutLMModel"),i(Ht,"href","https://github.com/tesseract-ocr/tesseract"),i(Ht,"rel","nofollow"),i(Kt,"href","https://pypi.org/project/pytesseract/"),i(Kt,"rel","nofollow"),i(In,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(Cn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),i($n,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config"),i(Fn,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained"),i(Zn,"href","layoutxlm"),i(He,"id","resources"),i(He,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(He,"href","#resources"),i(Ue,"class","relative group"),i(lo,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/RVL-CDIP/Fine_tuning_LayoutLMv2ForSequenceClassification_on_RVL_CDIP.ipynb"),i(lo,"rel","nofollow"),i(Nn,"href","../tasks/sequence_classification"),i(po,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/DocVQA/Fine_tuning_LayoutLMv2ForQuestionAnswering_on_DocVQA.ipynb"),i(po,"rel","nofollow"),i(Bn,"href","../tasks/question_answering"),i(Xn,"href","../tasks/document_question_answering"),i(ho,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/CORD/Fine_tuning_LayoutLMv2ForTokenClassification_on_CORD.ipynb"),i(ho,"rel","nofollow"),i(go,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLMv2/FUNSD/Fine_tuning_LayoutLMv2ForTokenClassification_on_FUNSD_using_HuggingFace_Trainer.ipynb"),i(go,"rel","nofollow"),i(Gn,"href","../tasks/token_classification"),i(et,"id","usage-layoutlmv2processor"),i(et,"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"),i(et,"href","#usage-layoutlmv2processor"),i(Ee,"class","relative group"),i(Sn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(Pn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),i(Dn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(Qn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),i(Yn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(On,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),i(Hn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(Kn,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),i(es,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(vo,"href","https://pypi.org/project/pytesseract/"),i(vo,"rel","nofollow"),i(ts,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor"),i(tt,"id","transformers.LayoutLMv2Config"),i(tt,"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"),i(tt,"href","#transformers.LayoutLMv2Config"),i(ze,"class","relative group"),i(ps,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),i(jo,"href","https://huggingface.co/microsoft/layoutlmv2-base-uncased"),i(jo,"rel","nofollow"),i(us,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(ms,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(nt,"id","transformers.LayoutLMv2FeatureExtractor"),i(nt,"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"),i(nt,"href","#transformers.LayoutLMv2FeatureExtractor"),i($e,"class","relative group"),i(st,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(at,"id","transformers.LayoutLMv2ImageProcessor"),i(at,"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"),i(at,"href","#transformers.LayoutLMv2ImageProcessor"),i(Ze,"class","relative group"),i(rt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(lt,"id","transformers.LayoutLMv2Tokenizer"),i(lt,"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"),i(lt,"href","#transformers.LayoutLMv2Tokenizer"),i(We,"class","relative group"),i(hs,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(fs,"href","/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),i(ys,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(it,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(_s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ct,"id","transformers.LayoutLMv2TokenizerFast"),i(ct,"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"),i(ct,"href","#transformers.LayoutLMv2TokenizerFast"),i(Re,"class","relative group"),i(vs,"href","/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),i(dt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(pt,"id","transformers.LayoutLMv2Processor"),i(pt,"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"),i(pt,"href","#transformers.LayoutLMv2Processor"),i(Ne,"class","relative group"),i(Ms,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(ws,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(Ls,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(ks,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),i(Po,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2FeatureExtractor.__call__"),i(Ts,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(Do,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__"),i(xs,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ut,"id","transformers.LayoutLMv2Model"),i(ut,"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"),i(ut,"href","#transformers.LayoutLMv2Model"),i(qe,"class","relative group"),i(Ho,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),i(Ho,"rel","nofollow"),i(js,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),i(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(de,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ft,"id","transformers.LayoutLMv2ForSequenceClassification"),i(ft,"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"),i(ft,"href","#transformers.LayoutLMv2ForSequenceClassification"),i(Ae,"class","relative group"),i(nn,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),i(nn,"rel","nofollow"),i(an,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),i(an,"rel","nofollow"),i(Js,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForSequenceClassification"),i(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(_t,"id","transformers.LayoutLMv2ForTokenClassification"),i(_t,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(_t,"href","#transformers.LayoutLMv2ForTokenClassification"),i(Ve,"class","relative group"),i(dn,"href","https://guillaumejaume.github.io/FUNSD/"),i(dn,"rel","nofollow"),i(pn,"href","https://rrc.cvc.uab.es/?ch=13"),i(pn,"rel","nofollow"),i(un,"href","https://github.com/clovaai/cord"),i(un,"rel","nofollow"),i(mn,"href","https://github.com/applicaai/kleister-nda"),i(mn,"rel","nofollow"),i(fn,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),i(fn,"rel","nofollow"),i(Us,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForTokenClassification"),i(le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Mt,"id","transformers.LayoutLMv2ForQuestionAnswering"),i(Mt,"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"),i(Mt,"href","#transformers.LayoutLMv2ForQuestionAnswering"),i(Se,"class","relative group"),i(vn,"href","https://rrc.cvc.uab.es/?ch=17"),i(vn,"rel","nofollow"),i(Mn,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),i(Mn,"rel","nofollow"),i(Es,"href","/docs/transformers/v4.30.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForQuestionAnswering"),i(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ne,"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,c){e(document.head,h),u(t,k,c),u(t,f,c),e(f,w),e(w,T),_(m,T,null),e(f,L),e(f,R),e(R,Di),u(t,Or,c),u(t,je,c),e(je,Qe),e(Qe,Qs),_(Ft,Qs,null),e(je,Qi),e(je,Ys),e(Ys,Yi),u(t,Hr,c),u(t,me,c),e(me,Oi),e(me,Zt),e(Zt,Hi),e(me,Ki),e(me,Tn),e(Tn,ec),e(me,tc),u(t,Kr,c),u(t,he,c),e(he,O),e(O,oc),e(O,Wt),e(Wt,nc),e(O,sc),e(O,Rt),e(Rt,ac),e(O,rc),e(O,Nt),e(Nt,lc),e(O,ic),e(O,qt),e(qt,cc),e(O,dc),e(he,pc),e(he,Bt),e(Bt,uc),e(Bt,At),e(At,mc),e(Bt,hc),e(he,fc),e(he,Xt),e(Xt,gc),e(Xt,Vt),e(Vt,yc),e(Xt,_c),u(t,el,c),u(t,xn,c),e(xn,vc),u(t,tl,c),u(t,jn,c),e(jn,Os),e(Os,bc),u(t,ol,c),u(t,se,c),e(se,Mc),e(se,Hs),e(Hs,wc),e(se,Lc),e(se,Ks),e(Ks,kc),e(se,Tc),e(se,ea),e(ea,xc),e(se,jc),u(t,nl,c),_(Gt,t,c),u(t,sl,c),u(t,Jn,c),e(Jn,Jc),u(t,al,c),u(t,Un,c),e(Un,Uc),u(t,rl,c),u(t,G,c),e(G,ta),e(ta,Ec),e(G,zc),e(G,St),e(St,Ic),e(St,Pt),e(Pt,Cc),e(St,$c),e(G,Fc),e(G,Dt),e(Dt,Zc),e(Dt,Qt),e(Qt,Wc),e(Dt,Rc),e(G,Nc),e(G,Je),e(Je,qc),e(Je,Yt),e(Yt,Bc),e(Je,Ac),e(Je,Ot),e(Ot,Xc),e(Je,Vc),e(G,Gc),e(G,x),e(x,Sc),e(x,oa),e(oa,Pc),e(x,Dc),e(x,En),e(En,Qc),e(x,Yc),e(x,na),e(na,Oc),e(x,Hc),e(x,sa),e(sa,Kc),e(x,ed),e(x,aa),e(aa,td),e(x,od),e(x,ra),e(ra,nd),e(x,sd),e(x,la),e(la,ad),e(x,rd),e(x,ia),e(ia,ld),e(x,id),e(x,ca),e(ca,cd),e(x,dd),e(x,zn),e(zn,pd),e(x,ud),e(x,Ht),e(Ht,md),e(x,hd),e(x,Kt),e(Kt,fd),e(x,gd),u(t,ll,c),_(eo,t,c),u(t,il,c),u(t,fe,c),e(fe,yd),e(fe,da),e(da,_d),e(fe,vd),e(fe,pa),e(pa,bd),e(fe,Md),u(t,cl,c),_(to,t,c),u(t,dl,c),u(t,Ye,c),e(Ye,wd),e(Ye,In),e(In,Ld),e(Ye,kd),u(t,pl,c),u(t,ge,c),e(ge,Z),e(Z,Td),e(Z,Cn),e(Cn,xd),e(Z,jd),e(Z,ua),e(ua,Jd),e(Z,Ud),e(Z,ma),e(ma,Ed),e(Z,zd),e(Z,$n),e($n,Id),e(Z,Cd),e(Z,ha),e(ha,$d),e(Z,Fd),e(Z,fa),e(fa,Zd),e(Z,Wd),e(Z,ga),e(ga,Rd),e(Z,Nd),e(ge,qd),e(ge,oo),e(oo,Bd),e(oo,Fn),e(Fn,Ad),e(oo,Xd),e(ge,Vd),e(ge,no),e(no,Gd),e(no,ya),e(ya,Sd),e(no,Pd),u(t,ul,c),u(t,Oe,c),e(Oe,Dd),e(Oe,Zn),e(Zn,Qd),e(Oe,Yd),u(t,ml,c),u(t,Ue,c),e(Ue,He),e(He,_a),_(so,_a,null),e(Ue,Od),e(Ue,va),e(va,Hd),u(t,hl,c),u(t,Wn,c),e(Wn,Kd),u(t,fl,c),_(ao,t,c),u(t,gl,c),u(t,Ke,c),e(Ke,ro),e(ro,ep),e(ro,lo),e(lo,tp),e(ro,op),e(Ke,np),e(Ke,Rn),e(Rn,sp),e(Rn,Nn),e(Nn,ap),u(t,yl,c),_(io,t,c),u(t,_l,c),u(t,ye,c),e(ye,co),e(co,rp),e(co,po),e(po,lp),e(co,ip),e(ye,cp),e(ye,qn),e(qn,dp),e(qn,Bn),e(Bn,pp),e(ye,up),e(ye,An),e(An,mp),e(An,Xn),e(Xn,hp),u(t,vl,c),_(uo,t,c),u(t,bl,c),u(t,_e,c),e(_e,mo),e(mo,fp),e(mo,ho),e(ho,gp),e(mo,yp),e(_e,_p),e(_e,fo),e(fo,vp),e(fo,go),e(go,bp),e(fo,Mp),e(_e,wp),e(_e,Vn),e(Vn,Lp),e(Vn,Gn),e(Gn,kp),u(t,Ml,c),u(t,Ee,c),e(Ee,et),e(et,ba),_(yo,ba,null),e(Ee,Tp),e(Ee,Ma),e(Ma,xp),u(t,wl,c),u(t,S,c),e(S,jp),e(S,Sn),e(Sn,Jp),e(S,Up),e(S,Pn),e(Pn,Ep),e(S,zp),e(S,Dn),e(Dn,Ip),e(S,Cp),e(S,Qn),e(Qn,$p),e(S,Fp),u(t,Ll,c),_(_o,t,c),u(t,kl,c),u(t,J,c),e(J,Zp),e(J,Yn),e(Yn,Wp),e(J,Rp),e(J,On),e(On,Np),e(J,qp),e(J,wa),e(wa,Bp),e(J,Ap),e(J,Hn),e(Hn,Xp),e(J,Vp),e(J,Kn),e(Kn,Gp),e(J,Sp),e(J,La),e(La,Pp),e(J,Dp),e(J,ka),e(ka,Qp),e(J,Yp),e(J,Ta),e(Ta,Op),e(J,Hp),e(J,xa),e(xa,Kp),e(J,eu),e(J,ja),e(ja,tu),e(J,ou),u(t,Tl,c),u(t,A,c),e(A,es),e(es,nu),e(A,su),e(A,vo),e(vo,au),e(A,ru),e(A,ts),e(ts,lu),e(A,iu),e(A,Ja),e(Ja,cu),e(A,du),e(A,Ua),e(Ua,pu),e(A,uu),u(t,xl,c),u(t,os,c),e(os,mu),u(t,jl,c),u(t,ns,c),e(ns,Ea),e(Ea,hu),u(t,Jl,c),u(t,ss,c),e(ss,fu),u(t,Ul,c),_(bo,t,c),u(t,El,c),u(t,as,c),e(as,za),e(za,gu),u(t,zl,c),u(t,ve,c),e(ve,yu),e(ve,Ia),e(Ia,_u),e(ve,vu),e(ve,Ca),e(Ca,bu),e(ve,Mu),u(t,Il,c),_(Mo,t,c),u(t,Cl,c),u(t,rs,c),e(rs,$a),e($a,wu),u(t,$l,c),u(t,P,c),e(P,Lu),e(P,Fa),e(Fa,ku),e(P,Tu),e(P,Za),e(Za,xu),e(P,ju),e(P,Wa),e(Wa,Ju),e(P,Uu),e(P,Ra),e(Ra,Eu),e(P,zu),u(t,Fl,c),_(wo,t,c),u(t,Zl,c),u(t,ls,c),e(ls,Na),e(Na,Iu),u(t,Wl,c),u(t,is,c),e(is,Cu),u(t,Rl,c),_(Lo,t,c),u(t,Nl,c),u(t,cs,c),e(cs,qa),e(qa,$u),u(t,ql,c),u(t,ds,c),e(ds,Fu),u(t,Bl,c),_(ko,t,c),u(t,Al,c),u(t,ze,c),e(ze,tt),e(tt,Ba),_(To,Ba,null),e(ze,Zu),e(ze,Aa),e(Aa,Wu),u(t,Xl,c),u(t,H,c),_(xo,H,null),e(H,Ru),e(H,Ie),e(Ie,Nu),e(Ie,ps),e(ps,qu),e(Ie,Bu),e(Ie,jo),e(jo,Au),e(Ie,Xu),e(H,Vu),e(H,Ce),e(Ce,Gu),e(Ce,us),e(us,Su),e(Ce,Pu),e(Ce,ms),e(ms,Du),e(Ce,Qu),e(H,Yu),_(ot,H,null),u(t,Vl,c),u(t,$e,c),e($e,nt),e(nt,Xa),_(Jo,Xa,null),e($e,Ou),e($e,Va),e(Va,Hu),u(t,Gl,c),u(t,Fe,c),_(Uo,Fe,null),e(Fe,Ku),e(Fe,st),_(Eo,st,null),e(st,em),e(st,Ga),e(Ga,tm),u(t,Sl,c),u(t,Ze,c),e(Ze,at),e(at,Sa),_(zo,Sa,null),e(Ze,om),e(Ze,Pa),e(Pa,nm),u(t,Pl,c),u(t,ce,c),_(Io,ce,null),e(ce,sm),e(ce,Da),e(Da,am),e(ce,rm),e(ce,rt),_(Co,rt,null),e(rt,lm),e(rt,Qa),e(Qa,im),u(t,Dl,c),u(t,We,c),e(We,lt),e(lt,Ya),_($o,Ya,null),e(We,cm),e(We,Oa),e(Oa,dm),u(t,Ql,c),u(t,N,c),_(Fo,N,null),e(N,pm),e(N,q),e(q,um),e(q,hs),e(hs,mm),e(q,hm),e(q,Ha),e(Ha,fm),e(q,gm),e(q,Ka),e(Ka,ym),e(q,_m),e(q,er),e(er,vm),e(q,bm),e(q,tr),e(tr,Mm),e(q,wm),e(q,or),e(or,Lm),e(q,km),e(N,Tm),e(N,Zo),e(Zo,xm),e(Zo,fs),e(fs,jm),e(Zo,Jm),e(N,Um),e(N,gs),e(gs,ys),e(ys,Em),e(gs,zm),e(N,Im),e(N,it),_(Wo,it,null),e(it,Cm),e(it,nr),e(nr,$m),e(N,Fm),e(N,_s),_(Ro,_s,null),u(t,Yl,c),u(t,Re,c),e(Re,ct),e(ct,sr),_(No,sr,null),e(Re,Zm),e(Re,ar),e(ar,Wm),u(t,Ol,c),u(t,K,c),_(qo,K,null),e(K,Rm),e(K,Bo),e(Bo,Nm),e(Bo,rr),e(rr,qm),e(Bo,Bm),e(K,Am),e(K,Ao),e(Ao,Xm),e(Ao,vs),e(vs,Vm),e(Ao,Gm),e(K,Sm),e(K,dt),_(Xo,dt,null),e(dt,Pm),e(dt,lr),e(lr,Dm),u(t,Hl,c),u(t,Ne,c),e(Ne,pt),e(pt,ir),_(Vo,ir,null),e(Ne,Qm),e(Ne,cr),e(cr,Ym),u(t,Kl,c),u(t,X,c),_(Go,X,null),e(X,Om),e(X,dr),e(dr,Hm),e(X,Km),e(X,bs),e(bs,Ms),e(Ms,eh),e(bs,th),e(X,oh),e(X,z),e(z,nh),e(z,ws),e(ws,sh),e(z,ah),e(z,Ls),e(Ls,rh),e(z,lh),e(z,ks),e(ks,ih),e(z,ch),e(z,pr),e(pr,dh),e(z,ph),e(z,ur),e(ur,uh),e(z,mh),e(z,mr),e(mr,hh),e(z,fh),e(z,hr),e(hr,gh),e(z,yh),e(z,fr),e(fr,_h),e(z,vh),e(z,gr),e(gr,bh),e(z,Mh),e(X,wh),e(X,be),_(So,be,null),e(be,Lh),e(be,j),e(j,kh),e(j,yr),e(yr,Th),e(j,xh),e(j,Po),e(Po,_r),e(_r,jh),e(Po,Jh),e(j,Uh),e(j,Ts),e(Ts,Eh),e(j,zh),e(j,vr),e(vr,Ih),e(j,Ch),e(j,br),e(br,$h),e(j,Fh),e(j,Do),e(Do,Mr),e(Mr,Zh),e(Do,Wh),e(j,Rh),e(j,wr),e(wr,Nh),e(j,qh),e(j,xs),e(xs,Bh),e(j,Ah),e(j,Lr),e(Lr,Xh),e(j,Vh),e(j,kr),e(kr,Gh),e(j,Sh),e(j,Tr),e(Tr,Ph),e(j,Dh),e(j,xr),e(xr,Qh),e(j,Yh),e(be,Oh),e(be,jr),e(jr,Hh),u(t,ei,c),u(t,qe,c),e(qe,ut),e(ut,Jr),_(Qo,Jr,null),e(qe,Kh),e(qe,Ur),e(Ur,ef),u(t,ti,c),u(t,de,c),_(Yo,de,null),e(de,tf),e(de,Oo),e(Oo,of),e(Oo,Ho),e(Ho,nf),e(Oo,sf),e(de,af),e(de,ae),_(Ko,ae,null),e(ae,rf),e(ae,Be),e(Be,lf),e(Be,js),e(js,cf),e(Be,df),e(Be,Er),e(Er,pf),e(Be,uf),e(ae,mf),_(mt,ae,null),e(ae,hf),_(ht,ae,null),u(t,oi,c),u(t,Ae,c),e(Ae,ft),e(ft,zr),_(en,zr,null),e(Ae,ff),e(Ae,Ir),e(Ir,gf),u(t,ni,c),u(t,ee,c),_(tn,ee,null),e(ee,yf),e(ee,on),e(on,_f),e(on,nn),e(nn,vf),e(on,bf),e(ee,Mf),e(ee,sn),e(sn,wf),e(sn,an),e(an,Lf),e(sn,kf),e(ee,Tf),e(ee,re),_(rn,re,null),e(re,xf),e(re,Xe),e(Xe,jf),e(Xe,Js),e(Js,Jf),e(Xe,Uf),e(Xe,Cr),e(Cr,Ef),e(Xe,zf),e(re,If),_(gt,re,null),e(re,Cf),_(yt,re,null),u(t,si,c),u(t,Ve,c),e(Ve,_t),e(_t,$r),_(ln,$r,null),e(Ve,$f),e(Ve,Fr),e(Fr,Ff),u(t,ai,c),u(t,te,c),_(cn,te,null),e(te,Zf),e(te,oe),e(oe,Wf),e(oe,dn),e(dn,Rf),e(oe,Nf),e(oe,pn),e(pn,qf),e(oe,Bf),e(oe,un),e(un,Af),e(oe,Xf),e(oe,mn),e(mn,Vf),e(oe,Gf),e(te,Sf),e(te,hn),e(hn,Pf),e(hn,fn),e(fn,Df),e(hn,Qf),e(te,Yf),e(te,le),_(gn,le,null),e(le,Of),e(le,Ge),e(Ge,Hf),e(Ge,Us),e(Us,Kf),e(Ge,eg),e(Ge,Zr),e(Zr,tg),e(Ge,og),e(le,ng),_(vt,le,null),e(le,sg),_(bt,le,null),u(t,ri,c),u(t,Se,c),e(Se,Mt),e(Mt,Wr),_(yn,Wr,null),e(Se,ag),e(Se,Rr),e(Rr,rg),u(t,li,c),u(t,ne,c),_(_n,ne,null),e(ne,lg),e(ne,pe),e(pe,ig),e(pe,vn),e(vn,cg),e(pe,dg),e(pe,Nr),e(Nr,pg),e(pe,ug),e(pe,qr),e(qr,mg),e(pe,hg),e(ne,fg),e(ne,bn),e(bn,gg),e(bn,Mn),e(Mn,yg),e(bn,_g),e(ne,vg),e(ne,W),_(wn,W,null),e(W,bg),e(W,Pe),e(Pe,Mg),e(Pe,Es),e(Es,wg),e(Pe,Lg),e(Pe,Br),e(Br,kg),e(Pe,Tg),e(W,xg),_(wt,W,null),e(W,jg),e(W,Ar),e(Ar,Jg),e(W,Ug),e(W,Xr),e(Xr,Eg),e(W,zg),_(Lt,W,null),e(W,Ig),_(kt,W,null),ii=!0},p(t,[c]){const Ln={};c&2&&(Ln.$$scope={dirty:c,ctx:t}),ot.$set(Ln);const Vr={};c&2&&(Vr.$$scope={dirty:c,ctx:t}),mt.$set(Vr);const Gr={};c&2&&(Gr.$$scope={dirty:c,ctx:t}),ht.$set(Gr);const Sr={};c&2&&(Sr.$$scope={dirty:c,ctx:t}),gt.$set(Sr);const kn={};c&2&&(kn.$$scope={dirty:c,ctx:t}),yt.$set(kn);const Pr={};c&2&&(Pr.$$scope={dirty:c,ctx:t}),vt.$set(Pr);const Dr={};c&2&&(Dr.$$scope={dirty:c,ctx:t}),bt.$set(Dr);const Qr={};c&2&&(Qr.$$scope={dirty:c,ctx:t}),wt.$set(Qr);const De={};c&2&&(De.$$scope={dirty:c,ctx:t}),Lt.$set(De);const Yr={};c&2&&(Yr.$$scope={dirty:c,ctx:t}),kt.$set(Yr)},i(t){ii||(v(m.$$.fragment,t),v(Ft.$$.fragment,t),v(Gt.$$.fragment,t),v(eo.$$.fragment,t),v(to.$$.fragment,t),v(so.$$.fragment,t),v(ao.$$.fragment,t),v(io.$$.fragment,t),v(uo.$$.fragment,t),v(yo.$$.fragment,t),v(_o.$$.fragment,t),v(bo.$$.fragment,t),v(Mo.$$.fragment,t),v(wo.$$.fragment,t),v(Lo.$$.fragment,t),v(ko.$$.fragment,t),v(To.$$.fragment,t),v(xo.$$.fragment,t),v(ot.$$.fragment,t),v(Jo.$$.fragment,t),v(Uo.$$.fragment,t),v(Eo.$$.fragment,t),v(zo.$$.fragment,t),v(Io.$$.fragment,t),v(Co.$$.fragment,t),v($o.$$.fragment,t),v(Fo.$$.fragment,t),v(Wo.$$.fragment,t),v(Ro.$$.fragment,t),v(No.$$.fragment,t),v(qo.$$.fragment,t),v(Xo.$$.fragment,t),v(Vo.$$.fragment,t),v(Go.$$.fragment,t),v(So.$$.fragment,t),v(Qo.$$.fragment,t),v(Yo.$$.fragment,t),v(Ko.$$.fragment,t),v(mt.$$.fragment,t),v(ht.$$.fragment,t),v(en.$$.fragment,t),v(tn.$$.fragment,t),v(rn.$$.fragment,t),v(gt.$$.fragment,t),v(yt.$$.fragment,t),v(ln.$$.fragment,t),v(cn.$$.fragment,t),v(gn.$$.fragment,t),v(vt.$$.fragment,t),v(bt.$$.fragment,t),v(yn.$$.fragment,t),v(_n.$$.fragment,t),v(wn.$$.fragment,t),v(wt.$$.fragment,t),v(Lt.$$.fragment,t),v(kt.$$.fragment,t),ii=!0)},o(t){b(m.$$.fragment,t),b(Ft.$$.fragment,t),b(Gt.$$.fragment,t),b(eo.$$.fragment,t),b(to.$$.fragment,t),b(so.$$.fragment,t),b(ao.$$.fragment,t),b(io.$$.fragment,t),b(uo.$$.fragment,t),b(yo.$$.fragment,t),b(_o.$$.fragment,t),b(bo.$$.fragment,t),b(Mo.$$.fragment,t),b(wo.$$.fragment,t),b(Lo.$$.fragment,t),b(ko.$$.fragment,t),b(To.$$.fragment,t),b(xo.$$.fragment,t),b(ot.$$.fragment,t),b(Jo.$$.fragment,t),b(Uo.$$.fragment,t),b(Eo.$$.fragment,t),b(zo.$$.fragment,t),b(Io.$$.fragment,t),b(Co.$$.fragment,t),b($o.$$.fragment,t),b(Fo.$$.fragment,t),b(Wo.$$.fragment,t),b(Ro.$$.fragment,t),b(No.$$.fragment,t),b(qo.$$.fragment,t),b(Xo.$$.fragment,t),b(Vo.$$.fragment,t),b(Go.$$.fragment,t),b(So.$$.fragment,t),b(Qo.$$.fragment,t),b(Yo.$$.fragment,t),b(Ko.$$.fragment,t),b(mt.$$.fragment,t),b(ht.$$.fragment,t),b(en.$$.fragment,t),b(tn.$$.fragment,t),b(rn.$$.fragment,t),b(gt.$$.fragment,t),b(yt.$$.fragment,t),b(ln.$$.fragment,t),b(cn.$$.fragment,t),b(gn.$$.fragment,t),b(vt.$$.fragment,t),b(bt.$$.fragment,t),b(yn.$$.fragment,t),b(_n.$$.fragment,t),b(wn.$$.fragment,t),b(wt.$$.fragment,t),b(Lt.$$.fragment,t),b(kt.$$.fragment,t),ii=!1},d(t){o(h),t&&o(k),t&&o(f),M(m),t&&o(Or),t&&o(je),M(Ft),t&&o(Hr),t&&o(me),t&&o(Kr),t&&o(he),t&&o(el),t&&o(xn),t&&o(tl),t&&o(jn),t&&o(ol),t&&o(se),t&&o(nl),M(Gt,t),t&&o(sl),t&&o(Jn),t&&o(al),t&&o(Un),t&&o(rl),t&&o(G),t&&o(ll),M(eo,t),t&&o(il),t&&o(fe),t&&o(cl),M(to,t),t&&o(dl),t&&o(Ye),t&&o(pl),t&&o(ge),t&&o(ul),t&&o(Oe),t&&o(ml),t&&o(Ue),M(so),t&&o(hl),t&&o(Wn),t&&o(fl),M(ao,t),t&&o(gl),t&&o(Ke),t&&o(yl),M(io,t),t&&o(_l),t&&o(ye),t&&o(vl),M(uo,t),t&&o(bl),t&&o(_e),t&&o(Ml),t&&o(Ee),M(yo),t&&o(wl),t&&o(S),t&&o(Ll),M(_o,t),t&&o(kl),t&&o(J),t&&o(Tl),t&&o(A),t&&o(xl),t&&o(os),t&&o(jl),t&&o(ns),t&&o(Jl),t&&o(ss),t&&o(Ul),M(bo,t),t&&o(El),t&&o(as),t&&o(zl),t&&o(ve),t&&o(Il),M(Mo,t),t&&o(Cl),t&&o(rs),t&&o($l),t&&o(P),t&&o(Fl),M(wo,t),t&&o(Zl),t&&o(ls),t&&o(Wl),t&&o(is),t&&o(Rl),M(Lo,t),t&&o(Nl),t&&o(cs),t&&o(ql),t&&o(ds),t&&o(Bl),M(ko,t),t&&o(Al),t&&o(ze),M(To),t&&o(Xl),t&&o(H),M(xo),M(ot),t&&o(Vl),t&&o($e),M(Jo),t&&o(Gl),t&&o(Fe),M(Uo),M(Eo),t&&o(Sl),t&&o(Ze),M(zo),t&&o(Pl),t&&o(ce),M(Io),M(Co),t&&o(Dl),t&&o(We),M($o),t&&o(Ql),t&&o(N),M(Fo),M(Wo),M(Ro),t&&o(Yl),t&&o(Re),M(No),t&&o(Ol),t&&o(K),M(qo),M(Xo),t&&o(Hl),t&&o(Ne),M(Vo),t&&o(Kl),t&&o(X),M(Go),M(So),t&&o(ei),t&&o(qe),M(Qo),t&&o(ti),t&&o(de),M(Yo),M(Ko),M(mt),M(ht),t&&o(oi),t&&o(Ae),M(en),t&&o(ni),t&&o(ee),M(tn),M(rn),M(gt),M(yt),t&&o(si),t&&o(Ve),M(ln),t&&o(ai),t&&o(te),M(cn),M(gn),M(vt),M(bt),t&&o(ri),t&&o(Se),M(yn),t&&o(li),t&&o(ne),M(_n),M(wn),M(wt),M(Lt),M(kt)}}}const Wb={local:"layoutlmv2",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"usage-layoutlmv2processor",title:"Usage: LayoutLMv2Processor"},{local:"transformers.LayoutLMv2Config",title:"LayoutLMv2Config"},{local:"transformers.LayoutLMv2FeatureExtractor",title:"LayoutLMv2FeatureExtractor"},{local:"transformers.LayoutLMv2ImageProcessor",title:"LayoutLMv2ImageProcessor"},{local:"transformers.LayoutLMv2Tokenizer",title:"LayoutLMv2Tokenizer"},{local:"transformers.LayoutLMv2TokenizerFast",title:"LayoutLMv2TokenizerFast"},{local:"transformers.LayoutLMv2Processor",title:"LayoutLMv2Processor"},{local:"transformers.LayoutLMv2Model",title:"LayoutLMv2Model"},{local:"transformers.LayoutLMv2ForSequenceClassification",title:"LayoutLMv2ForSequenceClassification"},{local:"transformers.LayoutLMv2ForTokenClassification",title:"LayoutLMv2ForTokenClassification"},{local:"transformers.LayoutLMv2ForQuestionAnswering",title:"LayoutLMv2ForQuestionAnswering"}],title:"LayoutLMV2"};function Rb(I){return Tb(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Sb extends Mb{constructor(h){super();wb(this,h,Rb,Zb,Lb,{})}}export{Sb as default,Wb as metadata};
