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 m,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 Si}from"../../chunks/Tip-hf-doc-builder.js";import{D as F}from"../../chunks/Docstring-hf-doc-builder.js";import{C as G}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Y}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ss}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 G({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(u){h=r(u,"P",{});var L=l(h);k=s(L,"Example:"),L.forEach(o),f=p(u),y(w.$$.fragment,u)},m(u,L){m(u,h,L),e(h,k),m(u,f,L),_(w,u,L),T=!0},p:Ds,i(u){T||(v(w.$$.fragment,u),T=!0)},o(u){b(w.$$.fragment,u),T=!1},d(u){u&&o(h),u&&o(f),M(w,u)}}}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(u){h=r(u,"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 N=l(f);w=s(N,"Module"),N.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(u,L){m(u,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(u){u&&o(h)}}}function Jb(I){let h,k,f,w,T;return w=new G({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(u){h=r(u,"P",{});var L=l(h);k=s(L,"Examples:"),L.forEach(o),f=p(u),y(w.$$.fragment,u)},m(u,L){m(u,h,L),e(h,k),m(u,f,L),_(w,u,L),T=!0},p:Ds,i(u){T||(v(w.$$.fragment,u),T=!0)},o(u){b(w.$$.fragment,u),T=!1},d(u){u&&o(h),u&&o(f),M(w,u)}}}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(u){h=r(u,"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 N=l(f);w=s(N,"Module"),N.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(u,L){m(u,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(u){u&&o(h)}}}function Eb(I){let h,k,f,w,T;return w=new G({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(u){h=r(u,"P",{});var L=l(h);k=s(L,"Example:"),L.forEach(o),f=p(u),y(w.$$.fragment,u)},m(u,L){m(u,h,L),e(h,k),m(u,f,L),_(w,u,L),T=!0},p:Ds,i(u){T||(v(w.$$.fragment,u),T=!0)},o(u){b(w.$$.fragment,u),T=!1},d(u){u&&o(h),u&&o(f),M(w,u)}}}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(u){h=r(u,"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 N=l(f);w=s(N,"Module"),N.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(u,L){m(u,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(u){u&&o(h)}}}function Ib(I){let h,k,f,w,T;return w=new G({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(u){h=r(u,"P",{});var L=l(h);k=s(L,"Example:"),L.forEach(o),f=p(u),y(w.$$.fragment,u)},m(u,L){m(u,h,L),e(h,k),m(u,f,L),_(w,u,L),T=!0},p:Ds,i(u){T||(v(w.$$.fragment,u),T=!0)},o(u){b(w.$$.fragment,u),T=!1},d(u){u&&o(h),u&&o(f),M(w,u)}}}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(u){h=r(u,"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 N=l(f);w=s(N,"Module"),N.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(u,L){m(u,h,L),e(h,k),e(h,f),e(f,w),e(h,T)},d(u){u&&o(h)}}}function $b(I){let h,k;return h=new G({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 G({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 Wb(I){let h,k,f,w,T,u,L,N,Di,Or,je,Qe,Qs,Ft,Qi,Ys,Yi,Hr,ue,Oi,Wt,Hi,Ki,Tn,ec,tc,Kr,he,O,oc,Zt,nc,sc,Nt,ac,rc,Rt,lc,ic,qt,cc,dc,pc,Bt,mc,At,uc,hc,fc,Vt,gc,Gt,yc,_c,el,xn,vc,tl,jn,Os,bc,ol,se,Mc,Hs,wc,Lc,Ks,kc,Tc,ea,xc,jc,nl,Xt,sl,Jn,Jc,al,Un,Uc,rl,X,ta,Ec,zc,Pt,Ic,St,Cc,$c,Fc,Dt,Wc,Qt,Zc,Nc,Rc,Je,qc,Yt,Bc,Ac,Ot,Vc,Gc,Xc,x,Pc,oa,Sc,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,md,Ht,ud,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,W,Td,Cn,xd,jd,ma,Jd,Ud,ua,Ed,zd,$n,Id,Cd,ha,$d,Fd,fa,Wd,Zd,ga,Nd,Rd,qd,oo,Bd,Fn,Ad,Vd,Gd,no,Xd,ya,Pd,Sd,ml,Oe,Dd,Wn,Qd,Yd,ul,Ue,He,_a,so,Od,va,Hd,hl,Zn,Kd,fl,ao,gl,Ke,ro,ep,lo,tp,op,np,Nn,sp,Rn,ap,yl,io,_l,ye,co,rp,po,lp,ip,cp,qn,dp,Bn,pp,mp,An,up,Vn,hp,vl,mo,bl,_e,uo,fp,ho,gp,yp,_p,fo,vp,go,bp,Mp,wp,Gn,Lp,Xn,kp,Ml,Ee,et,ba,yo,Tp,Ma,xp,wl,P,jp,Pn,Jp,Up,Sn,Ep,zp,Dn,Ip,Cp,Qn,$p,Fp,Ll,_o,kl,J,Wp,Yn,Zp,Np,On,Rp,qp,wa,Bp,Ap,Hn,Vp,Gp,Kn,Xp,Pp,La,Sp,Dp,ka,Qp,Yp,Ta,Op,Hp,xa,Kp,em,ja,tm,om,Tl,A,es,nm,sm,vo,am,rm,ts,lm,im,Ja,cm,dm,Ua,pm,mm,xl,os,um,jl,ns,Ea,hm,Jl,ss,fm,Ul,bo,El,as,za,gm,zl,ve,ym,Ia,_m,vm,Ca,bm,Mm,Il,Mo,Cl,rs,$a,wm,$l,S,Lm,Fa,km,Tm,Wa,xm,jm,Za,Jm,Um,Na,Em,zm,Fl,wo,Wl,ls,Ra,Im,Zl,is,Cm,Nl,Lo,Rl,cs,qa,$m,ql,ds,Fm,Bl,ko,Al,ze,tt,Ba,To,Wm,Aa,Zm,Vl,H,xo,Nm,Ie,Rm,ps,qm,Bm,jo,Am,Vm,Gm,Ce,Xm,ms,Pm,Sm,us,Dm,Qm,Ym,ot,Gl,$e,nt,Va,Jo,Om,Ga,Hm,Xl,Fe,Uo,Km,st,Eo,eu,Xa,tu,Pl,We,at,Pa,zo,ou,Sa,nu,Sl,ce,Io,su,Da,au,ru,rt,Co,lu,Qa,iu,Dl,Ze,lt,Ya,$o,cu,Oa,du,Ql,R,Fo,pu,q,mu,hs,uu,hu,Ha,fu,gu,Ka,yu,_u,er,vu,bu,tr,Mu,wu,or,Lu,ku,Tu,Wo,xu,fs,ju,Ju,Uu,gs,ys,Eu,zu,Iu,it,Zo,Cu,nr,$u,Fu,_s,No,Yl,Ne,ct,sr,Ro,Wu,ar,Zu,Ol,K,qo,Nu,Bo,Ru,rr,qu,Bu,Au,Ao,Vu,vs,Gu,Xu,Pu,dt,Vo,Su,lr,Du,Hl,Re,pt,ir,Go,Qu,cr,Yu,Kl,V,Xo,Ou,dr,Hu,Ku,bs,Ms,eh,th,oh,z,nh,ws,sh,ah,Ls,rh,lh,ks,ih,ch,pr,dh,ph,mr,mh,uh,ur,hh,fh,hr,gh,yh,fr,_h,vh,gr,bh,Mh,wh,be,Po,Lh,j,kh,yr,Th,xh,So,_r,jh,Jh,Uh,Ts,Eh,zh,vr,Ih,Ch,br,$h,Fh,Do,Mr,Wh,Zh,Nh,wr,Rh,qh,xs,Bh,Ah,Lr,Vh,Gh,kr,Xh,Ph,Tr,Sh,Dh,xr,Qh,Yh,Oh,jr,Hh,ei,qe,mt,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,mf,uf,ut,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,Ve,jf,Js,Jf,Uf,Cr,Ef,zf,If,gt,Cf,yt,si,Ge,_t,$r,ln,$f,Fr,Ff,ai,te,cn,Wf,oe,Zf,dn,Nf,Rf,pn,qf,Bf,mn,Af,Vf,un,Gf,Xf,Pf,hn,Sf,fn,Df,Qf,Yf,le,gn,Of,Xe,Hf,Us,Kf,eg,Wr,tg,og,ng,vt,sg,bt,ri,Pe,Mt,Zr,yn,ag,Nr,rg,li,ne,_n,lg,pe,ig,vn,cg,dg,Rr,pg,mg,qr,ug,hg,fg,bn,gg,Mn,yg,_g,vg,Z,wn,bg,Se,Mg,Es,wg,Lg,Br,kg,Tg,xg,wt,jg,Ar,Jg,Ug,Vr,Eg,zg,Lt,Ig,kt,ii;return u=new Y({}),Ft=new Y({}),Xt=new G({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 G({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 G({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"}}),mo=new Bg({props:{pipeline:"token-classification"}}),yo=new Y({}),_o=new G({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNdjJJbWFnZVByb2Nlc3NvciUyQyUyMExheW91dExNdjJUb2tlbml6ZXJGYXN0JTJDJTIwTGF5b3V0TE12MlByb2Nlc3NvciUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMExheW91dExNdjJJbWFnZVByb2Nlc3NvcigpJTIwJTIwJTIzJTIwYXBwbHlfb2NyJTIwaXMlMjBzZXQlMjB0byUyMFRydWUlMjBieSUyMGRlZmF1bHQlMEF0b2tlbml6ZXIlMjAlM0QlMjBMYXlvdXRMTXYyVG9rZW5pemVyRmFzdC5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGbGF5b3V0bG12Mi1iYXNlLXVuY2FzZWQlMjIpJTBBcHJvY2Vzc29yJTIwJTNEJTIwTGF5b3V0TE12MlByb2Nlc3NvcihpbWFnZV9wcm9jZXNzb3IlMkMlMjB0b2tlbml6ZXIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMv2ImageProcessor, LayoutLMv2TokenizerFast, LayoutLMv2Processor

image_processor = LayoutLMv2ImageProcessor()  <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(image_processor, tokenizer)`}}),bo=new G({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 G({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 G({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 G({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 G({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.31.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.31.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.31.0/src/transformers/models/layoutlmv2/configuration_layoutlmv2.py#L34"}}),ot=new Ss({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.31.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.31.0/src/transformers/image_processing_utils.py#L492"}}),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.31.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.31.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.31.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L206"}}),Zo=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.31.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.31.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.31.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.31.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.31.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L425",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),No=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.31.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py#L405"}}),Ro=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.31.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L70"}}),Vo=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.31.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.31.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.31.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.31.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.31.0/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py#L179",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.0/en/main_classes/tokenizer#transformers.BatchEncoding"
>BatchEncoding</a></p>
`}}),Go=new Y({}),Xo=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.31.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.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer">LayoutLMv2Tokenizer</a> or <a href="/docs/transformers/v4.31.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.31.0/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L27"}}),Po=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.31.0/src/transformers/models/layoutlmv2/processing_layoutlmv2.py#L68"}}),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.31.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.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L713"}}),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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L823",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ut=new Si({props:{$$slots:{default:[jb]},$$scope:{ctx:I}}}),ht=new Ss({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.31.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.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L974"}}),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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.31.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.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L988",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),gt=new Si({props:{$$slots:{default:[Ub]},$$scope:{ctx:I}}}),yt=new Ss({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.31.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.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1155"}}),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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.31.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.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1169",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),vt=new Si({props:{$$slots:{default:[zb]},$$scope:{ctx:I}}}),bt=new Ss({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.31.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.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1286"}}),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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.31.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.31.0/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py#L1300",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),wt=new Si({props:{$$slots:{default:[Cb]},$$scope:{ctx:I}}}),Lt=new Ss({props:{anchor:"transformers.LayoutLMv2ForQuestionAnswering.forward.example",$$slots:{default:[$b]},$$scope:{ctx:I}}}),kt=new Ss({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(u.$$.fragment),L=d(),N=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(),ue=a("p"),Oi=n("The LayoutLMV2 model was proposed in "),Wt=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 "),Zt=a("a"),nc=n("FUNSD"),sc=n(` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),Nt=a("a"),ac=n("CORD"),rc=n(`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),Rt=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"),mc=n("document image classification: the "),At=a("a"),uc=n("RVL-CDIP"),hc=n(` dataset (a collection of
400,000 images belonging to one of 16 classes).`),fc=d(),Vt=a("li"),gc=n("document visual question answering: the "),Gt=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(Xt.$$.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(),X=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(),Pt=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 `),St=a("a"),Cc=n("paper"),$c=n("."),Fc=d(),Dt=a("li"),Wc=n("Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),Qt=a("a"),Zc=n("here"),Nc=n("."),Rc=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"),Vc=n("this link"),Gc=n(` for installation
instructions.`),Xc=d(),x=a("li"),Pc=n("In addition to "),oa=a("code"),Sc=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"),md=n(`. These can be obtained using an
external OCR engine such as Google\u2019s `),Ht=a("a"),ud=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"),W=a("li"),Td=n("Internally, "),Cn=a("a"),xd=n("LayoutLMv2Model"),jd=n(" will send the "),ma=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 `),ua=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"),Wd=n("image_feature_pool_shape[0]"),Zd=n(` *
`),ga=a("code"),Nd=n("config.image_feature_pool_shape[1]"),Rd=n("."),qd=d(),oo=a("li"),Bd=n("When calling "),Fn=a("a"),Ad=n("from_pretrained()"),Vd=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.`),Gd=d(),no=a("li"),Xd=n("If you want to train the model in a distributed environment, make sure to call "),ya=a("code"),Pd=n("synchronize_batch_norm"),Sd=n(` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),ml=d(),Oe=a("p"),Dd=n(`In addition, there\u2019s LayoutXLM, which is a multilingual version of LayoutLMv2. More information can be found on
`),Wn=a("a"),Qd=n("LayoutXLM\u2019s documentation page"),Yd=n("."),ul=d(),Ue=a("h2"),He=a("a"),_a=a("span"),g(so.$$.fragment),Od=d(),va=a("span"),Hd=n("Resources"),hl=d(),Zn=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(),Nn=a("li"),sp=n("See also: "),Rn=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"),mp=d(),An=a("li"),up=n("See also: "),Vn=a("a"),hp=n("Document question answering task guide"),vl=d(),g(mo.$$.fragment),bl=d(),_e=a("ul"),uo=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(),Gn=a("li"),Lp=n("See also: "),Xn=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(),P=a("p"),jp=n("The easiest way to prepare data for the model is to use "),Pn=a("a"),Jp=n("LayoutLMv2Processor"),Up=n(`, which internally
combines a image processor (`),Sn=a("a"),Ep=n("LayoutLMv2ImageProcessor"),zp=n(`) and a tokenizer
(`),Dn=a("a"),Ip=n("LayoutLMv2Tokenizer"),Cp=n(" or "),Qn=a("a"),$p=n("LayoutLMv2TokenizerFast"),Fp=n(`). The image processor
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"),Wp=n("In short, one can provide a document image (and possibly additional data) to "),Yn=a("a"),Zp=n("LayoutLMv2Processor"),Np=n(`,
and it will create the inputs expected by the model. Internally, the processor first uses
`),On=a("a"),Rp=n("LayoutLMv2ImageProcessor"),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"),Vp=n("LayoutLMv2Tokenizer"),Gp=n(` or
`),Kn=a("a"),Xp=n("LayoutLMv2TokenizerFast"),Pp=n(", which converts them to token-level "),La=a("code"),Sp=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"),em=n(`. Optionally, one can provide word labels to the processor,
which are turned into token-level `),ja=a("code"),tm=n("labels"),om=n("."),Tl=d(),A=a("p"),es=a("a"),nm=n("LayoutLMv2Processor"),sm=n(" uses "),vo=a("a"),am=n("PyTesseract"),rm=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"),lm=n("LayoutLMv2ImageProcessor"),im=n(" with "),Ja=a("code"),cm=n("apply_ocr"),dm=n(" set to "),Ua=a("code"),pm=n("False"),mm=n("."),xl=d(),os=a("p"),um=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"),hm=n(`Use case 1: document image classification (training, inference) + token classification (inference), apply_ocr =
True`),Jl=d(),ss=a("p"),fm=n(`This is the simplest case, in which the processor (actually the image processor) 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"),gm=n("Use case 2: document image classification (training, inference) + token classification (inference), apply_ocr=False"),zl=d(),ve=a("p"),ym=n("In case one wants to do OCR themselves, one can initialize the image processor with "),Ia=a("code"),_m=n("apply_ocr"),vm=n(` set to
`),Ca=a("code"),bm=n("False"),Mm=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"),wm=n("Use case 3: token classification (training), apply_ocr=False"),$l=d(),S=a("p"),Lm=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"),km=n("labels"),Tm=n(`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Wa=a("code"),xm=n("ignore_index"),jm=n(` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Za=a("code"),Jm=n("only_label_first_subword"),Um=n(" set to "),Na=a("code"),Em=n("False"),zm=n("."),Fl=d(),g(wo.$$.fragment),Wl=d(),ls=a("p"),Ra=a("strong"),Im=n("Use case 4: visual question answering (inference), apply_ocr=True"),Zl=d(),is=a("p"),Cm=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].`),Nl=d(),g(Lo.$$.fragment),Rl=d(),cs=a("p"),qa=a("strong"),$m=n("Use case 5: visual question answering (inference), apply_ocr=False"),ql=d(),ds=a("p"),Fm=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),Wm=d(),Aa=a("span"),Zm=n("LayoutLMv2Config"),Vl=d(),H=a("div"),g(xo.$$.fragment),Nm=d(),Ie=a("p"),Rm=n("This is the configuration class to store the configuration of a "),ps=a("a"),qm=n("LayoutLMv2Model"),Bm=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"),Am=n("microsoft/layoutlmv2-base-uncased"),Vm=n(" architecture."),Gm=d(),Ce=a("p"),Xm=n("Configuration objects inherit from "),ms=a("a"),Pm=n("PretrainedConfig"),Sm=n(` and can be used to control the model outputs. Read the
documentation from `),us=a("a"),Dm=n("PretrainedConfig"),Qm=n(" for more information."),Ym=d(),g(ot.$$.fragment),Gl=d(),$e=a("h2"),nt=a("a"),Va=a("span"),g(Jo.$$.fragment),Om=d(),Ga=a("span"),Hm=n("LayoutLMv2FeatureExtractor"),Xl=d(),Fe=a("div"),g(Uo.$$.fragment),Km=d(),st=a("div"),g(Eo.$$.fragment),eu=d(),Xa=a("p"),tu=n("Preprocess an image or a batch of images."),Pl=d(),We=a("h2"),at=a("a"),Pa=a("span"),g(zo.$$.fragment),ou=d(),Sa=a("span"),nu=n("LayoutLMv2ImageProcessor"),Sl=d(),ce=a("div"),g(Io.$$.fragment),su=d(),Da=a("p"),au=n("Constructs a LayoutLMv2 image processor."),ru=d(),rt=a("div"),g(Co.$$.fragment),lu=d(),Qa=a("p"),iu=n("Preprocess an image or batch of images."),Dl=d(),Ze=a("h2"),lt=a("a"),Ya=a("span"),g($o.$$.fragment),cu=d(),Oa=a("span"),du=n("LayoutLMv2Tokenizer"),Ql=d(),R=a("div"),g(Fo.$$.fragment),pu=d(),q=a("p"),mu=n("Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),hs=a("a"),uu=n("LayoutLMv2Tokenizer"),hu=n(` can be used to turn words, word-level
bounding boxes and optional word labels to token-level `),Ha=a("code"),fu=n("input_ids"),gu=n(", "),Ka=a("code"),yu=n("attention_mask"),_u=n(", "),er=a("code"),vu=n("token_type_ids"),bu=n(", "),tr=a("code"),Mu=n("bbox"),wu=n(`, and
optional `),or=a("code"),Lu=n("labels"),ku=n(" (for token classification)."),Tu=d(),Wo=a("p"),xu=n("This tokenizer inherits from "),fs=a("a"),ju=n("PreTrainedTokenizer"),Ju=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Uu=d(),gs=a("p"),ys=a("a"),Eu=n("LayoutLMv2Tokenizer"),zu=n(` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Iu=d(),it=a("div"),g(Zo.$$.fragment),Cu=d(),nr=a("p"),$u=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.`),Fu=d(),_s=a("div"),g(No.$$.fragment),Yl=d(),Ne=a("h2"),ct=a("a"),sr=a("span"),g(Ro.$$.fragment),Wu=d(),ar=a("span"),Zu=n("LayoutLMv2TokenizerFast"),Ol=d(),K=a("div"),g(qo.$$.fragment),Nu=d(),Bo=a("p"),Ru=n("Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),rr=a("em"),qu=n("tokenizers"),Bu=n(" library). Based on WordPiece."),Au=d(),Ao=a("p"),Vu=n("This tokenizer inherits from "),vs=a("a"),Gu=n("PreTrainedTokenizerFast"),Xu=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Pu=d(),dt=a("div"),g(Vo.$$.fragment),Su=d(),lr=a("p"),Du=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(),Re=a("h2"),pt=a("a"),ir=a("span"),g(Go.$$.fragment),Qu=d(),cr=a("span"),Yu=n("LayoutLMv2Processor"),Kl=d(),V=a("div"),g(Xo.$$.fragment),Ou=d(),dr=a("p"),Hu=n(`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.`),Ku=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(`,
`),mr=a("code"),mh=n("attention_mask"),uh=n(", "),ur=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(Po.$$.fragment),Lh=d(),j=a("p"),kh=n("This method first forwards the "),yr=a("code"),Th=n("images"),xh=n(" argument to "),So=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"),Wh=n("call"),Zh=n("()"),Nh=n(` and returns the output,
together with resized `),wr=a("code"),Rh=n("images"),qh=n(". In case "),xs=a("a"),Bh=n("LayoutLMv2ImageProcessor"),Ah=n(" was initialized with "),Lr=a("code"),Vh=n("apply_ocr"),Gh=n(` set to
`),kr=a("code"),Xh=n("False"),Ph=n(", it passes the words ("),Tr=a("code"),Sh=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.31.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"),mt=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__"),mf=n(" special method."),uf=d(),g(ut.$$.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(),Ve=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(),Ge=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),Wf=d(),oe=a("p"),Zf=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"),Nf=n("FUNSD"),Rf=n(", "),pn=a("a"),qf=n("SROIE"),Bf=n(`,
`),mn=a("a"),Af=n("CORD"),Vf=n(" and "),un=a("a"),Gf=n("Kleister-NDA"),Xf=n("."),Pf=d(),hn=a("p"),Sf=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(),Xe=a("p"),Hf=n("The "),Us=a("a"),Kf=n("LayoutLMv2ForTokenClassification"),eg=n(" forward method, overrides the "),Wr=a("code"),tg=n("__call__"),og=n(" special method."),ng=d(),g(vt.$$.fragment),sg=d(),g(bt.$$.fragment),ri=d(),Pe=a("h2"),Mt=a("a"),Zr=a("span"),g(yn.$$.fragment),ag=d(),Nr=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 `),Rr=a("code"),pg=n("span start logits"),mg=n(" and "),qr=a("code"),ug=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(),Z=a("div"),g(wn.$$.fragment),bg=d(),Se=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(),Vr=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 Gr=l(w);T=r(Gr,"SPAN",{});var Xr=l(T);y(u.$$.fragment,Xr),Xr.forEach(o),Gr.forEach(o),L=p(Ln),N=r(Ln,"SPAN",{});var Pr=l(N);Di=s(Pr,"LayoutLMV2"),Pr.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 Sr=l(Qe);Qs=r(Sr,"SPAN",{});var Dr=l(Qs);y(Ft.$$.fragment,Dr),Dr.forEach(o),Sr.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),ue=r(t,"P",{});var De=l(ue);Oi=s(De,"The LayoutLMV2 model was proposed in "),Wt=r(De,"A",{href:!0,rel:!0});var Yr=l(Wt);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 "),Zt=r(Me,"A",{href:!0,rel:!0});var Vg=l(Zt);nc=s(Vg,"FUNSD"),Vg.forEach(o),sc=s(Me,` dataset (a
collection of 199 annotated forms comprising more than 30,000 words), the `),Nt=r(Me,"A",{href:!0,rel:!0});var Gg=l(Nt);ac=s(Gg,"CORD"),Gg.forEach(o),rc=s(Me,`
dataset (a collection of 800 receipts for training, 100 for validation and 100 for testing), the `),Rt=r(Me,"A",{href:!0,rel:!0});var Xg=l(Rt);lc=s(Xg,"SROIE"),Xg.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 Pg=l(qt);cc=s(Pg,"Kleister-NDA"),Pg.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);mc=s(ci,"document image classification: the "),At=r(ci,"A",{href:!0,rel:!0});var Sg=l(At);uc=s(Sg,"RVL-CDIP"),Sg.forEach(o),hc=s(ci,` dataset (a collection of
400,000 images belonging to one of 16 classes).`),ci.forEach(o),fc=p(zs),Vt=r(zs,"LI",{});var di=l(Vt);gc=s(di,"document visual question answering: the "),Gt=r(di,"A",{href:!0,rel:!0});var Dg=l(Gt);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(Xt.$$.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),X=r(t,"UL",{});var we=l(X);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),Pt=r(we,"LI",{});var pi=l(Pt);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 `),St=r(pi,"A",{href:!0,rel:!0});var sy=l(St);Cc=s(sy,"paper"),sy.forEach(o),$c=s(pi,"."),pi.forEach(o),Fc=p(we),Dt=r(we,"LI",{});var mi=l(Dt);Wc=s(mi,"Demo notebooks on how to use the LayoutLMv2 model on RVL-CDIP, FUNSD, DocVQA, CORD can be found "),Qt=r(mi,"A",{href:!0,rel:!0});var ay=l(Qt);Zc=s(ay,"here"),ay.forEach(o),Nc=s(mi,"."),mi.forEach(o),Rc=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);Vc=s(ly,"this link"),ly.forEach(o),Gc=s(Is,` for installation
instructions.`),Is.forEach(o),Xc=p(we),x=r(we,"LI",{});var U=l(x);Pc=s(U,"In addition to "),oa=r(U,"CODE",{});var iy=l(oa);Sc=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 my=l(aa);td=s(my,"image"),my.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 uy=l(ra);nd=s(uy,"image"),uy.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),md=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);ud=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 ui=l(Ye);wd=s(ui,"However, this model includes a brand new "),In=r(ui,"A",{href:!0});var wy=l(In);Ld=s(wy,"LayoutLMv2Processor"),wy.forEach(o),kd=s(ui,` 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.`),ui.forEach(o),pl=p(t),ge=r(t,"UL",{});var $s=l(ge);W=r($s,"LI",{});var B=l(W);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 "),ma=r(B,"CODE",{});var ky=l(ma);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 `),ua=r(B,"CODE",{});var Ty=l(ua);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);Wd=s(Jy,"image_feature_pool_shape[0]"),Jy.forEach(o),Zd=s(B,` *
`),ga=r(B,"CODE",{});var Uy=l(ga);Nd=s(Uy,"config.image_feature_pool_shape[1]"),Uy.forEach(o),Rd=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),Vd=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),Gd=p($s),no=r($s,"LI",{});var fi=l(no);Xd=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);Pd=s(zy,"synchronize_batch_norm"),zy.forEach(o),Sd=s(fi,` on the
model in order to properly synchronize the batch normalization layers of the visual backbone.`),fi.forEach(o),$s.forEach(o),ml=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
`),Wn=r(gi,"A",{href:!0});var Iy=l(Wn);Qd=s(Iy,"LayoutXLM\u2019s documentation page"),Iy.forEach(o),Yd=s(gi,"."),gi.forEach(o),ul=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),Zn=r(t,"P",{});var Wy=l(Zn);Kd=s(Wy,"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."),Wy.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 Zy=l(lo);tp=s(Zy,"finetune LayoutLMv2 for text-classification on RVL-CDIP dataset"),Zy.forEach(o),op=s(vi,"."),vi.forEach(o),np=p(_i),Nn=r(_i,"LI",{});var Cg=l(Nn);sp=s(Cg,"See also: "),Rn=r(Cg,"A",{href:!0});var Ny=l(Rn);ap=s(Ny,"Text classification task guide"),Ny.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 Ry=l(po);lp=s(Ry,"finetune LayoutLMv2 for question-answering on DocVQA dataset"),Ry.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),mp=p(Fs),An=r(Fs,"LI",{});var Fg=l(An);up=s(Fg,"See also: "),Vn=r(Fg,"A",{href:!0});var By=l(Vn);hp=s(By,"Document question answering task guide"),By.forEach(o),Fg.forEach(o),Fs.forEach(o),vl=p(t),y(mo.$$.fragment,t),bl=p(t),_e=r(t,"UL",{});var Ws=l(_e);uo=r(Ws,"LI",{});var Mi=l(uo);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(Ws),fo=r(Ws,"LI",{});var wi=l(fo);vp=s(wi,"A notebook on how to "),go=r(wi,"A",{href:!0,rel:!0});var Vy=l(go);bp=s(Vy,"finetune LayoutLMv2 for token-classification on FUNSD dataset"),Vy.forEach(o),Mp=s(wi,"."),wi.forEach(o),wp=p(Ws),Gn=r(Ws,"LI",{});var Wg=l(Gn);Lp=s(Wg,"See also: "),Xn=r(Wg,"A",{href:!0});var Gy=l(Xn);kp=s(Gy,"Token classification task guide"),Gy.forEach(o),Wg.forEach(o),Ws.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 Xy=l(et);ba=r(Xy,"SPAN",{});var Py=l(ba);y(yo.$$.fragment,Py),Py.forEach(o),Xy.forEach(o),Tp=p(Li),Ma=r(Li,"SPAN",{});var Sy=l(Ma);xp=s(Sy,"Usage: LayoutLMv2Processor"),Sy.forEach(o),Li.forEach(o),wl=p(t),P=r(t,"P",{});var Le=l(P);jp=s(Le,"The easiest way to prepare data for the model is to use "),Pn=r(Le,"A",{href:!0});var Dy=l(Pn);Jp=s(Dy,"LayoutLMv2Processor"),Dy.forEach(o),Up=s(Le,`, which internally
combines a image processor (`),Sn=r(Le,"A",{href:!0});var Qy=l(Sn);Ep=s(Qy,"LayoutLMv2ImageProcessor"),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 image processor
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);Wp=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);Zp=s(Hy,"LayoutLMv2Processor"),Hy.forEach(o),Np=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);Rp=s(Ky,"LayoutLMv2ImageProcessor"),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);Vp=s(t_,"LayoutLMv2Tokenizer"),t_.forEach(o),Gp=s(C,` or
`),Kn=r(C,"A",{href:!0});var o_=l(Kn);Xp=s(o_,"LayoutLMv2TokenizerFast"),o_.forEach(o),Pp=s(C,", which converts them to token-level "),La=r(C,"CODE",{});var n_=l(La);Sp=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),em=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);tm=s(l_,"labels"),l_.forEach(o),om=s(C,"."),C.forEach(o),Tl=p(t),A=r(t,"P",{});var me=l(A);es=r(me,"A",{href:!0});var i_=l(es);nm=s(i_,"LayoutLMv2Processor"),i_.forEach(o),sm=s(me," uses "),vo=r(me,"A",{href:!0,rel:!0});var c_=l(vo);am=s(c_,"PyTesseract"),c_.forEach(o),rm=s(me,`, 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(me,"A",{href:!0});var d_=l(ts);lm=s(d_,"LayoutLMv2ImageProcessor"),d_.forEach(o),im=s(me," with "),Ja=r(me,"CODE",{});var p_=l(Ja);cm=s(p_,"apply_ocr"),p_.forEach(o),dm=s(me," set to "),Ua=r(me,"CODE",{});var m_=l(Ua);pm=s(m_,"False"),m_.forEach(o),mm=s(me,"."),me.forEach(o),xl=p(t),os=r(t,"P",{});var u_=l(os);um=s(u_,`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).`),u_.forEach(o),jl=p(t),ns=r(t,"P",{});var h_=l(ns);Ea=r(h_,"STRONG",{});var f_=l(Ea);hm=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);fm=s(g_,`This is the simplest case, in which the processor (actually the image processor) 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);gm=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 Zs=l(ve);ym=s(Zs,"In case one wants to do OCR themselves, one can initialize the image processor with "),Ia=r(Zs,"CODE",{});var v_=l(Ia);_m=s(v_,"apply_ocr"),v_.forEach(o),vm=s(Zs,` set to
`),Ca=r(Zs,"CODE",{});var b_=l(Ca);bm=s(b_,"False"),b_.forEach(o),Mm=s(Zs,`. In that case, one should provide the words and corresponding (normalized) bounding boxes themselves to
the processor.`),Zs.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);wm=s(w_,"Use case 3: token classification (training), apply_ocr=False"),w_.forEach(o),M_.forEach(o),$l=p(t),S=r(t,"P",{});var ke=l(S);Lm=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);km=s(L_,"labels"),L_.forEach(o),Tm=s(ke,`. By default, it
will only label the first wordpiece of a word, and label the remaining wordpieces with -100, which is the
`),Wa=r(ke,"CODE",{});var k_=l(Wa);xm=s(k_,"ignore_index"),k_.forEach(o),jm=s(ke,` of PyTorch\u2019s CrossEntropyLoss. In case you want all wordpieces of a word to be labeled, you can
initialize the tokenizer with `),Za=r(ke,"CODE",{});var T_=l(Za);Jm=s(T_,"only_label_first_subword"),T_.forEach(o),Um=s(ke," set to "),Na=r(ke,"CODE",{});var x_=l(Na);Em=s(x_,"False"),x_.forEach(o),zm=s(ke,"."),ke.forEach(o),Fl=p(t),y(wo.$$.fragment,t),Wl=p(t),ls=r(t,"P",{});var j_=l(ls);Ra=r(j_,"STRONG",{});var J_=l(Ra);Im=s(J_,"Use case 4: visual question answering (inference), apply_ocr=True"),J_.forEach(o),j_.forEach(o),Zl=p(t),is=r(t,"P",{});var U_=l(is);Cm=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),Nl=p(t),y(Lo.$$.fragment,t),Rl=p(t),cs=r(t,"P",{});var E_=l(cs);qa=r(E_,"STRONG",{});var z_=l(qa);$m=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);Fm=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),Wm=p(ki),Aa=r(ki,"SPAN",{});var F_=l(Aa);Zm=s(F_,"LayoutLMv2Config"),F_.forEach(o),ki.forEach(o),Vl=p(t),H=r(t,"DIV",{class:!0});var xt=l(H);y(xo.$$.fragment,xt),Nm=p(xt),Ie=r(xt,"P",{});var Ns=l(Ie);Rm=s(Ns,"This is the configuration class to store the configuration of a "),ps=r(Ns,"A",{href:!0});var W_=l(ps);qm=s(W_,"LayoutLMv2Model"),W_.forEach(o),Bm=s(Ns,`. 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(Ns,"A",{href:!0,rel:!0});var Z_=l(jo);Am=s(Z_,"microsoft/layoutlmv2-base-uncased"),Z_.forEach(o),Vm=s(Ns," architecture."),Ns.forEach(o),Gm=p(xt),Ce=r(xt,"P",{});var Rs=l(Ce);Xm=s(Rs,"Configuration objects inherit from "),ms=r(Rs,"A",{href:!0});var N_=l(ms);Pm=s(N_,"PretrainedConfig"),N_.forEach(o),Sm=s(Rs,` and can be used to control the model outputs. Read the
documentation from `),us=r(Rs,"A",{href:!0});var R_=l(us);Dm=s(R_,"PretrainedConfig"),R_.forEach(o),Qm=s(Rs," for more information."),Rs.forEach(o),Ym=p(xt),y(ot.$$.fragment,xt),xt.forEach(o),Gl=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);Va=r(q_,"SPAN",{});var B_=l(Va);y(Jo.$$.fragment,B_),B_.forEach(o),q_.forEach(o),Om=p(Ti),Ga=r(Ti,"SPAN",{});var A_=l(Ga);Hm=s(A_,"LayoutLMv2FeatureExtractor"),A_.forEach(o),Ti.forEach(o),Xl=p(t),Fe=r(t,"DIV",{class:!0});var xi=l(Fe);y(Uo.$$.fragment,xi),Km=p(xi),st=r(xi,"DIV",{class:!0});var ji=l(st);y(Eo.$$.fragment,ji),eu=p(ji),Xa=r(ji,"P",{});var V_=l(Xa);tu=s(V_,"Preprocess an image or a batch of images."),V_.forEach(o),ji.forEach(o),xi.forEach(o),Pl=p(t),We=r(t,"H2",{class:!0});var Ji=l(We);at=r(Ji,"A",{id:!0,class:!0,href:!0});var G_=l(at);Pa=r(G_,"SPAN",{});var X_=l(Pa);y(zo.$$.fragment,X_),X_.forEach(o),G_.forEach(o),ou=p(Ji),Sa=r(Ji,"SPAN",{});var P_=l(Sa);nu=s(P_,"LayoutLMv2ImageProcessor"),P_.forEach(o),Ji.forEach(o),Sl=p(t),ce=r(t,"DIV",{class:!0});var qs=l(ce);y(Io.$$.fragment,qs),su=p(qs),Da=r(qs,"P",{});var S_=l(Da);au=s(S_,"Constructs a LayoutLMv2 image processor."),S_.forEach(o),ru=p(qs),rt=r(qs,"DIV",{class:!0});var Ui=l(rt);y(Co.$$.fragment,Ui),lu=p(Ui),Qa=r(Ui,"P",{});var D_=l(Qa);iu=s(D_,"Preprocess an image or batch of images."),D_.forEach(o),Ui.forEach(o),qs.forEach(o),Dl=p(t),Ze=r(t,"H2",{class:!0});var Ei=l(Ze);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),cu=p(Ei),Oa=r(Ei,"SPAN",{});var O_=l(Oa);du=s(O_,"LayoutLMv2Tokenizer"),O_.forEach(o),Ei.forEach(o),Ql=p(t),R=r(t,"DIV",{class:!0});var ie=l(R);y(Fo.$$.fragment,ie),pu=p(ie),q=r(ie,"P",{});var D=l(q);mu=s(D,"Construct a LayoutLMv2 tokenizer. Based on WordPiece. "),hs=r(D,"A",{href:!0});var H_=l(hs);uu=s(H_,"LayoutLMv2Tokenizer"),H_.forEach(o),hu=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);fu=s(K_,"input_ids"),K_.forEach(o),gu=s(D,", "),Ka=r(D,"CODE",{});var ev=l(Ka);yu=s(ev,"attention_mask"),ev.forEach(o),_u=s(D,", "),er=r(D,"CODE",{});var tv=l(er);vu=s(tv,"token_type_ids"),tv.forEach(o),bu=s(D,", "),tr=r(D,"CODE",{});var ov=l(tr);Mu=s(ov,"bbox"),ov.forEach(o),wu=s(D,`, and
optional `),or=r(D,"CODE",{});var nv=l(or);Lu=s(nv,"labels"),nv.forEach(o),ku=s(D," (for token classification)."),D.forEach(o),Tu=p(ie),Wo=r(ie,"P",{});var zi=l(Wo);xu=s(zi,"This tokenizer inherits from "),fs=r(zi,"A",{href:!0});var sv=l(fs);ju=s(sv,"PreTrainedTokenizer"),sv.forEach(o),Ju=s(zi,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),zi.forEach(o),Uu=p(ie),gs=r(ie,"P",{});var Zg=l(gs);ys=r(Zg,"A",{href:!0});var av=l(ys);Eu=s(av,"LayoutLMv2Tokenizer"),av.forEach(o),zu=s(Zg,` runs end-to-end tokenization: punctuation splitting and wordpiece. It also turns the
word-level bounding boxes into token-level bounding boxes.`),Zg.forEach(o),Iu=p(ie),it=r(ie,"DIV",{class:!0});var Ii=l(it);y(Zo.$$.fragment,Ii),Cu=p(Ii),nr=r(Ii,"P",{});var rv=l(nr);$u=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),Fu=p(ie),_s=r(ie,"DIV",{class:!0});var lv=l(_s);y(No.$$.fragment,lv),lv.forEach(o),ie.forEach(o),Yl=p(t),Ne=r(t,"H2",{class:!0});var Ci=l(Ne);ct=r(Ci,"A",{id:!0,class:!0,href:!0});var iv=l(ct);sr=r(iv,"SPAN",{});var cv=l(sr);y(Ro.$$.fragment,cv),cv.forEach(o),iv.forEach(o),Wu=p(Ci),ar=r(Ci,"SPAN",{});var dv=l(ar);Zu=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),Nu=p(jt),Bo=r(jt,"P",{});var $i=l(Bo);Ru=s($i,"Construct a \u201Cfast\u201D LayoutLMv2 tokenizer (backed by HuggingFace\u2019s "),rr=r($i,"EM",{});var pv=l(rr);qu=s(pv,"tokenizers"),pv.forEach(o),Bu=s($i," library). Based on WordPiece."),$i.forEach(o),Au=p(jt),Ao=r(jt,"P",{});var Fi=l(Ao);Vu=s(Fi,"This tokenizer inherits from "),vs=r(Fi,"A",{href:!0});var mv=l(vs);Gu=s(mv,"PreTrainedTokenizerFast"),mv.forEach(o),Xu=s(Fi,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Fi.forEach(o),Pu=p(jt),dt=r(jt,"DIV",{class:!0});var Wi=l(dt);y(Vo.$$.fragment,Wi),Su=p(Wi),lr=r(Wi,"P",{});var uv=l(lr);Du=s(uv,`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.`),uv.forEach(o),Wi.forEach(o),jt.forEach(o),Hl=p(t),Re=r(t,"H2",{class:!0});var Zi=l(Re);pt=r(Zi,"A",{id:!0,class:!0,href:!0});var hv=l(pt);ir=r(hv,"SPAN",{});var fv=l(ir);y(Go.$$.fragment,fv),fv.forEach(o),hv.forEach(o),Qu=p(Zi),cr=r(Zi,"SPAN",{});var gv=l(cr);Yu=s(gv,"LayoutLMv2Processor"),gv.forEach(o),Zi.forEach(o),Kl=p(t),V=r(t,"DIV",{class:!0});var Te=l(V);y(Xo.$$.fragment,Te),Ou=p(Te),dr=r(Te,"P",{});var yv=l(dr);Hu=s(yv,`Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.`),yv.forEach(o),Ku=p(Te),bs=r(Te,"P",{});var Ng=l(bs);Ms=r(Ng,"A",{href:!0});var _v=l(Ms);eh=s(_v,"LayoutLMv2Processor"),_v.forEach(o),th=s(Ng," offers all the functionalities you need to prepare data for the model."),Ng.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($,`,
`),mr=r($,"CODE",{});var Lv=l(mr);mh=s(Lv,"attention_mask"),Lv.forEach(o),uh=s($,", "),ur=r($,"CODE",{});var kv=l(ur);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(Po.$$.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 "),So=r(E,"A",{href:!0});var Rg=l(So);_r=r(Rg,"STRONG",{});var Uv=l(_r);jh=s(Uv,"call"),Uv.forEach(o),Jh=s(Rg,"()"),Rg.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);Wh=s(Cv,"call"),Cv.forEach(o),Zh=s(qg,"()"),qg.forEach(o),Nh=s(E,` and returns the output,
together with resized `),wr=r(E,"CODE",{});var $v=l(wr);Rh=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 Wv=l(Lr);Vh=s(Wv,"apply_ocr"),Wv.forEach(o),Gh=s(E,` set to
`),kr=r(E,"CODE",{});var Zv=l(kr);Xh=s(Zv,"False"),Zv.forEach(o),Ph=s(E,", it passes the words ("),Tr=r(E,"CODE",{});var Nv=l(Tr);Sh=s(Nv,"text"),Nv.forEach(o),Dh=s(E,"/"),xr=r(E,"CODE",{});var Rv=l(xr);Qh=s(Rv,"text_pair`) and `boxes` specified by the user along with the additional arguments to [__call__()](/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__) and returns the output, together with resized `images"),Rv.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 Ni=l(qe);mt=r(Ni,"A",{id:!0,class:!0,href:!0});var Bv=l(mt);Jr=r(Bv,"SPAN",{});var Av=l(Jr);y(Qo.$$.fragment,Av),Av.forEach(o),Bv.forEach(o),Kh=p(Ni),Ur=r(Ni,"SPAN",{});var Vv=l(Ur);ef=s(Vv,"LayoutLMv2Model"),Vv.forEach(o),Ni.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 Ri=l(Oo);of=s(Ri,`The bare LayoutLMv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Ho=r(Ri,"A",{href:!0,rel:!0});var Gv=l(Ho);nf=s(Gv,"torch.nn.Module"),Gv.forEach(o),sf=s(Ri,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ri.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 Vs=l(Be);lf=s(Vs,"The "),js=r(Vs,"A",{href:!0});var Xv=l(js);cf=s(Xv,"LayoutLMv2Model"),Xv.forEach(o),df=s(Vs," forward method, overrides the "),Er=r(Vs,"CODE",{});var Pv=l(Er);pf=s(Pv,"__call__"),Pv.forEach(o),mf=s(Vs," special method."),Vs.forEach(o),uf=p(Jt),y(ut.$$.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 Sv=l(ft);zr=r(Sv,"SPAN",{});var Dv=l(zr);y(en.$$.fragment,Dv),Dv.forEach(o),Sv.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),Ve=r(Et,"P",{});var Gs=l(Ve);jf=s(Gs,"The "),Js=r(Gs,"A",{href:!0});var Hv=l(Js);Jf=s(Hv,"LayoutLMv2ForSequenceClassification"),Hv.forEach(o),Uf=s(Gs," forward method, overrides the "),Cr=r(Gs,"CODE",{});var Kv=l(Cr);Ef=s(Kv,"__call__"),Kv.forEach(o),zf=s(Gs," special method."),Gs.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),Ge=r(t,"H2",{class:!0});var Vi=l(Ge);_t=r(Vi,"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(Vi),Fr=r(Vi,"SPAN",{});var ob=l(Fr);Ff=s(ob,"LayoutLMv2ForTokenClassification"),ob.forEach(o),Vi.forEach(o),ai=p(t),te=r(t,"DIV",{class:!0});var zt=l(te);y(cn.$$.fragment,zt),Wf=p(zt),oe=r(zt,"P",{});var xe=l(oe);Zf=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);Nf=s(nb,"FUNSD"),nb.forEach(o),Rf=s(xe,", "),pn=r(xe,"A",{href:!0,rel:!0});var sb=l(pn);qf=s(sb,"SROIE"),sb.forEach(o),Bf=s(xe,`,
`),mn=r(xe,"A",{href:!0,rel:!0});var ab=l(mn);Af=s(ab,"CORD"),ab.forEach(o),Vf=s(xe," and "),un=r(xe,"A",{href:!0,rel:!0});var rb=l(un);Gf=s(rb,"Kleister-NDA"),rb.forEach(o),Xf=s(xe,"."),xe.forEach(o),Pf=p(zt),hn=r(zt,"P",{});var Gi=l(hn);Sf=s(Gi,"This model is a PyTorch "),fn=r(Gi,"A",{href:!0,rel:!0});var lb=l(fn);Df=s(lb,"torch.nn.Module"),lb.forEach(o),Qf=s(Gi,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Gi.forEach(o),Yf=p(zt),le=r(zt,"DIV",{class:!0});var It=l(le);y(gn.$$.fragment,It),Of=p(It),Xe=r(It,"P",{});var Xs=l(Xe);Hf=s(Xs,"The "),Us=r(Xs,"A",{href:!0});var ib=l(Us);Kf=s(ib,"LayoutLMv2ForTokenClassification"),ib.forEach(o),eg=s(Xs," forward method, overrides the "),Wr=r(Xs,"CODE",{});var cb=l(Wr);tg=s(cb,"__call__"),cb.forEach(o),og=s(Xs," special method."),Xs.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),Pe=r(t,"H2",{class:!0});var Xi=l(Pe);Mt=r(Xi,"A",{id:!0,class:!0,href:!0});var db=l(Mt);Zr=r(db,"SPAN",{});var pb=l(Zr);y(yn.$$.fragment,pb),pb.forEach(o),db.forEach(o),ag=p(Xi),Nr=r(Xi,"SPAN",{});var mb=l(Nr);rg=s(mb,"LayoutLMv2ForQuestionAnswering"),mb.forEach(o),Xi.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 ub=l(vn);cg=s(ub,"DocVQA"),ub.forEach(o),dg=s($t,` (a linear layer on top of the text part of the hidden-states output to
compute `),Rr=r($t,"CODE",{});var hb=l(Rr);pg=s(hb,"span start logits"),hb.forEach(o),mg=s($t," and "),qr=r($t,"CODE",{});var fb=l(qr);ug=s(fb,"span end logits"),fb.forEach(o),hg=s($t,")."),$t.forEach(o),fg=p(Ct),bn=r(Ct,"P",{});var Pi=l(bn);gg=s(Pi,"This model is a PyTorch "),Mn=r(Pi,"A",{href:!0,rel:!0});var gb=l(Mn);yg=s(gb,"torch.nn.Module"),gb.forEach(o),_g=s(Pi,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Pi.forEach(o),vg=p(Ct),Z=r(Ct,"DIV",{class:!0});var Q=l(Z);y(wn.$$.fragment,Q),bg=p(Q),Se=r(Q,"P",{});var Ps=l(Se);Mg=s(Ps,"The "),Es=r(Ps,"A",{href:!0});var yb=l(Es);wg=s(yb,"LayoutLMv2ForQuestionAnswering"),yb.forEach(o),Lg=s(Ps," forward method, overrides the "),Br=r(Ps,"CODE",{});var _b=l(Br);kg=s(_b,"__call__"),_b.forEach(o),Tg=s(Ps," special method."),Ps.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),Vr=r(Q,"P",{});var bb=l(Vr);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(Zb)),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(Wt,"href","https://arxiv.org/abs/2012.14740"),i(Wt,"rel","nofollow"),i(Tn,"href","layoutlm"),i(Zt,"href","https://guillaumejaume.github.io/FUNSD/"),i(Zt,"rel","nofollow"),i(Nt,"href","https://github.com/clovaai/cord"),i(Nt,"rel","nofollow"),i(Rt,"href","https://rrc.cvc.uab.es/?ch=13"),i(Rt,"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(Gt,"href","https://arxiv.org/abs/2007.00398"),i(Gt,"rel","nofollow"),i(St,"href","https://arxiv.org/abs/2012.14740"),i(St,"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.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model.forward"),i(zn,"href","/docs/transformers/v4.31.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.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(Cn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),i($n,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Config"),i(Fn,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained"),i(Wn,"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(Rn,"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(Vn,"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(Xn,"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(Pn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(Sn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(Dn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(Qn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),i(Yn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(On,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(Hn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(Kn,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),i(es,"href","/docs/transformers/v4.31.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.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),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.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Model"),i(jo,"href","https://huggingface.co/microsoft/layoutlmv2-base-uncased"),i(jo,"rel","nofollow"),i(ms,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(us,"href","/docs/transformers/v4.31.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(We,"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(Ze,"class","relative group"),i(hs,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(fs,"href","/docs/transformers/v4.31.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),i(ys,"href","/docs/transformers/v4.31.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(R,"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(Ne,"class","relative group"),i(vs,"href","/docs/transformers/v4.31.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(Re,"class","relative group"),i(Ms,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Processor"),i(ws,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(Ls,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer"),i(ks,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2TokenizerFast"),i(So,"href","/docs/transformers/v4.31.0/en/model_doc/perceiver#transformers.PerceiverFeatureExtractor.__call__"),i(Ts,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor"),i(Do,"href","/docs/transformers/v4.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2Tokenizer.__call__"),i(xs,"href","/docs/transformers/v4.31.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(V,"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.LayoutLMv2Model"),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.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.31.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.31.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(Ge,"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(mn,"href","https://github.com/clovaai/cord"),i(mn,"rel","nofollow"),i(un,"href","https://github.com/applicaai/kleister-nda"),i(un,"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.31.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(Pe,"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.31.0/en/model_doc/layoutlmv2#transformers.LayoutLMv2ForQuestionAnswering"),i(Z,"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),m(t,k,c),m(t,f,c),e(f,w),e(w,T),_(u,T,null),e(f,L),e(f,N),e(N,Di),m(t,Or,c),m(t,je,c),e(je,Qe),e(Qe,Qs),_(Ft,Qs,null),e(je,Qi),e(je,Ys),e(Ys,Yi),m(t,Hr,c),m(t,ue,c),e(ue,Oi),e(ue,Wt),e(Wt,Hi),e(ue,Ki),e(ue,Tn),e(Tn,ec),e(ue,tc),m(t,Kr,c),m(t,he,c),e(he,O),e(O,oc),e(O,Zt),e(Zt,nc),e(O,sc),e(O,Nt),e(Nt,ac),e(O,rc),e(O,Rt),e(Rt,lc),e(O,ic),e(O,qt),e(qt,cc),e(O,dc),e(he,pc),e(he,Bt),e(Bt,mc),e(Bt,At),e(At,uc),e(Bt,hc),e(he,fc),e(he,Vt),e(Vt,gc),e(Vt,Gt),e(Gt,yc),e(Vt,_c),m(t,el,c),m(t,xn,c),e(xn,vc),m(t,tl,c),m(t,jn,c),e(jn,Os),e(Os,bc),m(t,ol,c),m(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),m(t,nl,c),_(Xt,t,c),m(t,sl,c),m(t,Jn,c),e(Jn,Jc),m(t,al,c),m(t,Un,c),e(Un,Uc),m(t,rl,c),m(t,X,c),e(X,ta),e(ta,Ec),e(X,zc),e(X,Pt),e(Pt,Ic),e(Pt,St),e(St,Cc),e(Pt,$c),e(X,Fc),e(X,Dt),e(Dt,Wc),e(Dt,Qt),e(Qt,Zc),e(Dt,Nc),e(X,Rc),e(X,Je),e(Je,qc),e(Je,Yt),e(Yt,Bc),e(Je,Ac),e(Je,Ot),e(Ot,Vc),e(Je,Gc),e(X,Xc),e(X,x),e(x,Pc),e(x,oa),e(oa,Sc),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,md),e(x,Ht),e(Ht,ud),e(x,hd),e(x,Kt),e(Kt,fd),e(x,gd),m(t,ll,c),_(eo,t,c),m(t,il,c),m(t,fe,c),e(fe,yd),e(fe,da),e(da,_d),e(fe,vd),e(fe,pa),e(pa,bd),e(fe,Md),m(t,cl,c),_(to,t,c),m(t,dl,c),m(t,Ye,c),e(Ye,wd),e(Ye,In),e(In,Ld),e(Ye,kd),m(t,pl,c),m(t,ge,c),e(ge,W),e(W,Td),e(W,Cn),e(Cn,xd),e(W,jd),e(W,ma),e(ma,Jd),e(W,Ud),e(W,ua),e(ua,Ed),e(W,zd),e(W,$n),e($n,Id),e(W,Cd),e(W,ha),e(ha,$d),e(W,Fd),e(W,fa),e(fa,Wd),e(W,Zd),e(W,ga),e(ga,Nd),e(W,Rd),e(ge,qd),e(ge,oo),e(oo,Bd),e(oo,Fn),e(Fn,Ad),e(oo,Vd),e(ge,Gd),e(ge,no),e(no,Xd),e(no,ya),e(ya,Pd),e(no,Sd),m(t,ml,c),m(t,Oe,c),e(Oe,Dd),e(Oe,Wn),e(Wn,Qd),e(Oe,Yd),m(t,ul,c),m(t,Ue,c),e(Ue,He),e(He,_a),_(so,_a,null),e(Ue,Od),e(Ue,va),e(va,Hd),m(t,hl,c),m(t,Zn,c),e(Zn,Kd),m(t,fl,c),_(ao,t,c),m(t,gl,c),m(t,Ke,c),e(Ke,ro),e(ro,ep),e(ro,lo),e(lo,tp),e(ro,op),e(Ke,np),e(Ke,Nn),e(Nn,sp),e(Nn,Rn),e(Rn,ap),m(t,yl,c),_(io,t,c),m(t,_l,c),m(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,mp),e(ye,An),e(An,up),e(An,Vn),e(Vn,hp),m(t,vl,c),_(mo,t,c),m(t,bl,c),m(t,_e,c),e(_e,uo),e(uo,fp),e(uo,ho),e(ho,gp),e(uo,yp),e(_e,_p),e(_e,fo),e(fo,vp),e(fo,go),e(go,bp),e(fo,Mp),e(_e,wp),e(_e,Gn),e(Gn,Lp),e(Gn,Xn),e(Xn,kp),m(t,Ml,c),m(t,Ee,c),e(Ee,et),e(et,ba),_(yo,ba,null),e(Ee,Tp),e(Ee,Ma),e(Ma,xp),m(t,wl,c),m(t,P,c),e(P,jp),e(P,Pn),e(Pn,Jp),e(P,Up),e(P,Sn),e(Sn,Ep),e(P,zp),e(P,Dn),e(Dn,Ip),e(P,Cp),e(P,Qn),e(Qn,$p),e(P,Fp),m(t,Ll,c),_(_o,t,c),m(t,kl,c),m(t,J,c),e(J,Wp),e(J,Yn),e(Yn,Zp),e(J,Np),e(J,On),e(On,Rp),e(J,qp),e(J,wa),e(wa,Bp),e(J,Ap),e(J,Hn),e(Hn,Vp),e(J,Gp),e(J,Kn),e(Kn,Xp),e(J,Pp),e(J,La),e(La,Sp),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,em),e(J,ja),e(ja,tm),e(J,om),m(t,Tl,c),m(t,A,c),e(A,es),e(es,nm),e(A,sm),e(A,vo),e(vo,am),e(A,rm),e(A,ts),e(ts,lm),e(A,im),e(A,Ja),e(Ja,cm),e(A,dm),e(A,Ua),e(Ua,pm),e(A,mm),m(t,xl,c),m(t,os,c),e(os,um),m(t,jl,c),m(t,ns,c),e(ns,Ea),e(Ea,hm),m(t,Jl,c),m(t,ss,c),e(ss,fm),m(t,Ul,c),_(bo,t,c),m(t,El,c),m(t,as,c),e(as,za),e(za,gm),m(t,zl,c),m(t,ve,c),e(ve,ym),e(ve,Ia),e(Ia,_m),e(ve,vm),e(ve,Ca),e(Ca,bm),e(ve,Mm),m(t,Il,c),_(Mo,t,c),m(t,Cl,c),m(t,rs,c),e(rs,$a),e($a,wm),m(t,$l,c),m(t,S,c),e(S,Lm),e(S,Fa),e(Fa,km),e(S,Tm),e(S,Wa),e(Wa,xm),e(S,jm),e(S,Za),e(Za,Jm),e(S,Um),e(S,Na),e(Na,Em),e(S,zm),m(t,Fl,c),_(wo,t,c),m(t,Wl,c),m(t,ls,c),e(ls,Ra),e(Ra,Im),m(t,Zl,c),m(t,is,c),e(is,Cm),m(t,Nl,c),_(Lo,t,c),m(t,Rl,c),m(t,cs,c),e(cs,qa),e(qa,$m),m(t,ql,c),m(t,ds,c),e(ds,Fm),m(t,Bl,c),_(ko,t,c),m(t,Al,c),m(t,ze,c),e(ze,tt),e(tt,Ba),_(To,Ba,null),e(ze,Wm),e(ze,Aa),e(Aa,Zm),m(t,Vl,c),m(t,H,c),_(xo,H,null),e(H,Nm),e(H,Ie),e(Ie,Rm),e(Ie,ps),e(ps,qm),e(Ie,Bm),e(Ie,jo),e(jo,Am),e(Ie,Vm),e(H,Gm),e(H,Ce),e(Ce,Xm),e(Ce,ms),e(ms,Pm),e(Ce,Sm),e(Ce,us),e(us,Dm),e(Ce,Qm),e(H,Ym),_(ot,H,null),m(t,Gl,c),m(t,$e,c),e($e,nt),e(nt,Va),_(Jo,Va,null),e($e,Om),e($e,Ga),e(Ga,Hm),m(t,Xl,c),m(t,Fe,c),_(Uo,Fe,null),e(Fe,Km),e(Fe,st),_(Eo,st,null),e(st,eu),e(st,Xa),e(Xa,tu),m(t,Pl,c),m(t,We,c),e(We,at),e(at,Pa),_(zo,Pa,null),e(We,ou),e(We,Sa),e(Sa,nu),m(t,Sl,c),m(t,ce,c),_(Io,ce,null),e(ce,su),e(ce,Da),e(Da,au),e(ce,ru),e(ce,rt),_(Co,rt,null),e(rt,lu),e(rt,Qa),e(Qa,iu),m(t,Dl,c),m(t,Ze,c),e(Ze,lt),e(lt,Ya),_($o,Ya,null),e(Ze,cu),e(Ze,Oa),e(Oa,du),m(t,Ql,c),m(t,R,c),_(Fo,R,null),e(R,pu),e(R,q),e(q,mu),e(q,hs),e(hs,uu),e(q,hu),e(q,Ha),e(Ha,fu),e(q,gu),e(q,Ka),e(Ka,yu),e(q,_u),e(q,er),e(er,vu),e(q,bu),e(q,tr),e(tr,Mu),e(q,wu),e(q,or),e(or,Lu),e(q,ku),e(R,Tu),e(R,Wo),e(Wo,xu),e(Wo,fs),e(fs,ju),e(Wo,Ju),e(R,Uu),e(R,gs),e(gs,ys),e(ys,Eu),e(gs,zu),e(R,Iu),e(R,it),_(Zo,it,null),e(it,Cu),e(it,nr),e(nr,$u),e(R,Fu),e(R,_s),_(No,_s,null),m(t,Yl,c),m(t,Ne,c),e(Ne,ct),e(ct,sr),_(Ro,sr,null),e(Ne,Wu),e(Ne,ar),e(ar,Zu),m(t,Ol,c),m(t,K,c),_(qo,K,null),e(K,Nu),e(K,Bo),e(Bo,Ru),e(Bo,rr),e(rr,qu),e(Bo,Bu),e(K,Au),e(K,Ao),e(Ao,Vu),e(Ao,vs),e(vs,Gu),e(Ao,Xu),e(K,Pu),e(K,dt),_(Vo,dt,null),e(dt,Su),e(dt,lr),e(lr,Du),m(t,Hl,c),m(t,Re,c),e(Re,pt),e(pt,ir),_(Go,ir,null),e(Re,Qu),e(Re,cr),e(cr,Yu),m(t,Kl,c),m(t,V,c),_(Xo,V,null),e(V,Ou),e(V,dr),e(dr,Hu),e(V,Ku),e(V,bs),e(bs,Ms),e(Ms,eh),e(bs,th),e(V,oh),e(V,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,mr),e(mr,mh),e(z,uh),e(z,ur),e(ur,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(V,wh),e(V,be),_(Po,be,null),e(be,Lh),e(be,j),e(j,kh),e(j,yr),e(yr,Th),e(j,xh),e(j,So),e(So,_r),e(_r,jh),e(So,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,Wh),e(Do,Zh),e(j,Nh),e(j,wr),e(wr,Rh),e(j,qh),e(j,xs),e(xs,Bh),e(j,Ah),e(j,Lr),e(Lr,Vh),e(j,Gh),e(j,kr),e(kr,Xh),e(j,Ph),e(j,Tr),e(Tr,Sh),e(j,Dh),e(j,xr),e(xr,Qh),e(j,Yh),e(be,Oh),e(be,jr),e(jr,Hh),m(t,ei,c),m(t,qe,c),e(qe,mt),e(mt,Jr),_(Qo,Jr,null),e(qe,Kh),e(qe,Ur),e(Ur,ef),m(t,ti,c),m(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,mf),e(ae,uf),_(ut,ae,null),e(ae,hf),_(ht,ae,null),m(t,oi,c),m(t,Ae,c),e(Ae,ft),e(ft,zr),_(en,zr,null),e(Ae,ff),e(Ae,Ir),e(Ir,gf),m(t,ni,c),m(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,Ve),e(Ve,jf),e(Ve,Js),e(Js,Jf),e(Ve,Uf),e(Ve,Cr),e(Cr,Ef),e(Ve,zf),e(re,If),_(gt,re,null),e(re,Cf),_(yt,re,null),m(t,si,c),m(t,Ge,c),e(Ge,_t),e(_t,$r),_(ln,$r,null),e(Ge,$f),e(Ge,Fr),e(Fr,Ff),m(t,ai,c),m(t,te,c),_(cn,te,null),e(te,Wf),e(te,oe),e(oe,Zf),e(oe,dn),e(dn,Nf),e(oe,Rf),e(oe,pn),e(pn,qf),e(oe,Bf),e(oe,mn),e(mn,Af),e(oe,Vf),e(oe,un),e(un,Gf),e(oe,Xf),e(te,Pf),e(te,hn),e(hn,Sf),e(hn,fn),e(fn,Df),e(hn,Qf),e(te,Yf),e(te,le),_(gn,le,null),e(le,Of),e(le,Xe),e(Xe,Hf),e(Xe,Us),e(Us,Kf),e(Xe,eg),e(Xe,Wr),e(Wr,tg),e(Xe,og),e(le,ng),_(vt,le,null),e(le,sg),_(bt,le,null),m(t,ri,c),m(t,Pe,c),e(Pe,Mt),e(Mt,Zr),_(yn,Zr,null),e(Pe,ag),e(Pe,Nr),e(Nr,rg),m(t,li,c),m(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,Rr),e(Rr,pg),e(pe,mg),e(pe,qr),e(qr,ug),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,Z),_(wn,Z,null),e(Z,bg),e(Z,Se),e(Se,Mg),e(Se,Es),e(Es,wg),e(Se,Lg),e(Se,Br),e(Br,kg),e(Se,Tg),e(Z,xg),_(wt,Z,null),e(Z,jg),e(Z,Ar),e(Ar,Jg),e(Z,Ug),e(Z,Vr),e(Vr,Eg),e(Z,zg),_(Lt,Z,null),e(Z,Ig),_(kt,Z,null),ii=!0},p(t,[c]){const Ln={};c&2&&(Ln.$$scope={dirty:c,ctx:t}),ot.$set(Ln);const Gr={};c&2&&(Gr.$$scope={dirty:c,ctx:t}),ut.$set(Gr);const Xr={};c&2&&(Xr.$$scope={dirty:c,ctx:t}),ht.$set(Xr);const Pr={};c&2&&(Pr.$$scope={dirty:c,ctx:t}),gt.$set(Pr);const kn={};c&2&&(kn.$$scope={dirty:c,ctx:t}),yt.$set(kn);const Sr={};c&2&&(Sr.$$scope={dirty:c,ctx:t}),vt.$set(Sr);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(u.$$.fragment,t),v(Ft.$$.fragment,t),v(Xt.$$.fragment,t),v(eo.$$.fragment,t),v(to.$$.fragment,t),v(so.$$.fragment,t),v(ao.$$.fragment,t),v(io.$$.fragment,t),v(mo.$$.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(Zo.$$.fragment,t),v(No.$$.fragment,t),v(Ro.$$.fragment,t),v(qo.$$.fragment,t),v(Vo.$$.fragment,t),v(Go.$$.fragment,t),v(Xo.$$.fragment,t),v(Po.$$.fragment,t),v(Qo.$$.fragment,t),v(Yo.$$.fragment,t),v(Ko.$$.fragment,t),v(ut.$$.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(u.$$.fragment,t),b(Ft.$$.fragment,t),b(Xt.$$.fragment,t),b(eo.$$.fragment,t),b(to.$$.fragment,t),b(so.$$.fragment,t),b(ao.$$.fragment,t),b(io.$$.fragment,t),b(mo.$$.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(Zo.$$.fragment,t),b(No.$$.fragment,t),b(Ro.$$.fragment,t),b(qo.$$.fragment,t),b(Vo.$$.fragment,t),b(Go.$$.fragment,t),b(Xo.$$.fragment,t),b(Po.$$.fragment,t),b(Qo.$$.fragment,t),b(Yo.$$.fragment,t),b(Ko.$$.fragment,t),b(ut.$$.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(u),t&&o(Or),t&&o(je),M(Ft),t&&o(Hr),t&&o(ue),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(Xt,t),t&&o(sl),t&&o(Jn),t&&o(al),t&&o(Un),t&&o(rl),t&&o(X),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(ml),t&&o(Oe),t&&o(ul),t&&o(Ue),M(so),t&&o(hl),t&&o(Zn),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(mo,t),t&&o(bl),t&&o(_e),t&&o(Ml),t&&o(Ee),M(yo),t&&o(wl),t&&o(P),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(S),t&&o(Fl),M(wo,t),t&&o(Wl),t&&o(ls),t&&o(Zl),t&&o(is),t&&o(Nl),M(Lo,t),t&&o(Rl),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(Vl),t&&o(H),M(xo),M(ot),t&&o(Gl),t&&o($e),M(Jo),t&&o(Xl),t&&o(Fe),M(Uo),M(Eo),t&&o(Pl),t&&o(We),M(zo),t&&o(Sl),t&&o(ce),M(Io),M(Co),t&&o(Dl),t&&o(Ze),M($o),t&&o(Ql),t&&o(R),M(Fo),M(Zo),M(No),t&&o(Yl),t&&o(Ne),M(Ro),t&&o(Ol),t&&o(K),M(qo),M(Vo),t&&o(Hl),t&&o(Re),M(Go),t&&o(Kl),t&&o(V),M(Xo),M(Po),t&&o(ei),t&&o(qe),M(Qo),t&&o(ti),t&&o(de),M(Yo),M(Ko),M(ut),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(Ge),M(ln),t&&o(ai),t&&o(te),M(cn),M(gn),M(vt),M(bt),t&&o(ri),t&&o(Pe),M(yn),t&&o(li),t&&o(ne),M(_n),M(wn),M(wt),M(Lt),M(kt)}}}const Zb={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 Nb(I){return Tb(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pb extends Mb{constructor(h){super();wb(this,h,Nb,Wb,Lb,{})}}export{Pb as default,Zb as metadata};
