import{S as VM,i as WM,s as QM,e as a,k as c,w,t as n,M as BM,c as r,d as t,m as p,a as l,x as k,h as s,b as u,G as e,g as m,y as v,q as L,o as j,B as U,v as GM,L as gt}from"../../chunks/vendor-hf-doc-builder.js";import{T as pt}from"../../chunks/Tip-hf-doc-builder.js";import{D as ne}from"../../chunks/Docstring-hf-doc-builder.js";import{C as it}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ot}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ft}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Hg}from"../../chunks/PipelineTag-hf-doc-builder.js";function DM(F){let d,b,f,g,M;return g=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMExheW91dExNQ29uZmlnJTJDJTIwTGF5b3V0TE1Nb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBMYXlvdXRMTSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwTGF5b3V0TE1Db25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwTGF5b3V0TE1Nb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LayoutLMConfig, LayoutLMModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a LayoutLM configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = LayoutLMConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMModel(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(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function XM(F){let d,b,f,g,M;return g=new it({props:{code:"MCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMEElN0MlMjBmaXJzdCUyMHNlcXVlbmNlJTIwJTIwJTIwJTIwJTdDJTIwc2Vjb25kJTIwc2VxdWVuY2UlMjAlN0M=",highlighted:`0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1 1
| first sequence    | second sequence |`}}),{c(){d=a("p"),b=n("sequence pair mask has the following format:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"sequence pair mask has the following format:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function SM(F){let d,b,f,g,M;return g=new it({props:{code:"MCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAwJTIwMCUyMDAlMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMjAxJTIwMSUyMDElMEElN0MlMjBmaXJzdCUyMHNlcXVlbmNlJTIwJTIwJTIwJTIwJTdDJTIwc2Vjb25kJTIwc2VxdWVuY2UlMjAlN0M=",highlighted:`0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 0 </span>0<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1<span class="hljs-number"> 1 </span>1 1
| first sequence    | second sequence |`}}),{c(){d=a("p"),b=n("sequence pair mask has the following format:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"sequence pair mask has the following format:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function PM(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function HM(F){let d,b,f,g,M;return g=new it({props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ZXMlMjAlMkIlMjAlNUIlNUIxMDAwJTJDJTIwMTAwMCUyQyUyMDEwMDAlMkMlMjAxMDAwJTVEJTVEJTBBJTBBZW5jb2RpbmclMjAlM0QlMjB0b2tlbml6ZXIoJTIyJTIwJTIyLmpvaW4od29yZHMpJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFpbnB1dF9pZHMlMjAlM0QlMjBlbmNvZGluZyU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQWF0dGVudGlvbl9tYXNrJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJhdHRlbnRpb25fbWFzayUyMiU1RCUwQXRva2VuX3R5cGVfaWRzJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJ0b2tlbl90eXBlX2lkcyUyMiU1RCUwQWJib3glMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCdG9rZW5fYm94ZXMlNUQpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGJib3glM0RiYm94JTJDJTIwYXR0ZW50aW9uX21hc2slM0RhdHRlbnRpb25fbWFzayUyQyUyMHRva2VuX3R5cGVfaWRzJTNEdG9rZW5fdHlwZV9pZHMlMEEpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, LayoutLMModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMModel.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = torch.tensor([token_boxes])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids, bbox=bbox, attention_mask=attention_mask, token_type_ids=token_type_ids
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function OM(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function YM(F){let d,b,f,g,M;return g=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBMYXlvdXRMTUZvck1hc2tlZExNJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbS1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBMYXlvdXRMTUZvck1hc2tlZExNL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2slMjAlM0QlMjBlbmNvZGluZyU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTVEJTBBdG9rZW5fdHlwZV9pZHMlMjAlM0QlMjBlbmNvZGluZyU1QiUyMnRva2VuX3R5cGVfaWRzJTIyJTVEJTBBYmJveCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUJ0b2tlbl9ib3hlcyU1RCklMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMjB3b3JsZCUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGJib3glM0RiYm94JTJDJTBBJTIwJTIwJTIwJTIwYXR0ZW50aW9uX21hc2slM0RhdHRlbnRpb25fbWFzayUyQyUwQSUyMCUyMCUyMCUyMHRva2VuX3R5cGVfaWRzJTNEdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjBsYWJlbHMlM0RsYWJlbHMlMkMlMEEpJTBBJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, LayoutLMForMaskedLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMForMaskedLM.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;[MASK]&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = torch.tensor([token_boxes])

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;Hello world&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids,
<span class="hljs-meta">... </span>    bbox=bbox,
<span class="hljs-meta">... </span>    attention_mask=attention_mask,
<span class="hljs-meta">... </span>    token_type_ids=token_type_ids,
<span class="hljs-meta">... </span>    labels=labels,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function KM(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function eb(F){let d,b,f,g,M;return g=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBMYXlvdXRMTUZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9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yMiUyMCUyMi5qb2luKHdvcmRzKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBaW5wdXRfaWRzJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFhdHRlbnRpb25fbWFzayUyMCUzRCUyMGVuY29kaW5nJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlNUQlMEF0b2tlbl90eXBlX2lkcyUyMCUzRCUyMGVuY29kaW5nJTVCJTIydG9rZW5fdHlwZV9pZHMlMjIlNUQlMEFiYm94JTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QnRva2VuX2JveGVzJTVEKSUwQXNlcXVlbmNlX2xhYmVsJTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QjElNUQpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGJib3glM0RiYm94JTJDJTBBJTIwJTIwJTIwJTIwYXR0ZW50aW9uX21hc2slM0RhdHRlbnRpb25fbWFzayUyQyUwQSUyMCUyMCUyMCUyMHRva2VuX3R5cGVfaWRzJTNEdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjBsYWJlbHMlM0RzZXF1ZW5jZV9sYWJlbCUyQyUwQSklMEElMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, LayoutLMForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = torch.tensor([token_boxes])
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence_label = torch.tensor([<span class="hljs-number">1</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids,
<span class="hljs-meta">... </span>    bbox=bbox,
<span class="hljs-meta">... </span>    attention_mask=attention_mask,
<span class="hljs-meta">... </span>    token_type_ids=token_type_ids,
<span class="hljs-meta">... </span>    labels=sequence_label,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function tb(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function ob(F){let d,b,f,g,M;return g=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMj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UyQyUyMDEwMDAlMkMlMjAxMDAwJTJDJTIwMTAwMCU1RCU1RCUwQSUwQWVuY29kaW5nJTIwJTNEJTIwdG9rZW5pemVyKCUyMiUyMCUyMi5qb2luKHdvcmRzKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBaW5wdXRfaWRzJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFhdHRlbnRpb25fbWFzayUyMCUzRCUyMGVuY29kaW5nJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlNUQlMEF0b2tlbl90eXBlX2lkcyUyMCUzRCUyMGVuY29kaW5nJTVCJTIydG9rZW5fdHlwZV9pZHMlMjIlNUQlMEFiYm94JTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QnRva2VuX2JveGVzJTVEKSUwQXRva2VuX2xhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxJTJDJTIwMSUyQyUyMDAlMkMlMjAwJTVEKS51bnNxdWVlemUoMCklMjAlMjAlMjMlMjBiYXRjaCUyMHNpemUlMjBvZiUyMDElMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoJTBBJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTBBJTIwJTIwJTIwJTIwYmJveCUzRGJib3glMkMlMEElMjAlMjAlMjAlMjBhdHRlbnRpb25fbWFzayUzRGF0dGVudGlvbl9tYXNrJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5fdHlwZV9pZHMlM0R0b2tlbl90eXBlX2lkcyUyQyUwQSUyMCUyMCUyMCUyMGxhYmVscyUzRHRva2VuX2xhYmVscyUyQyUwQSklMEElMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, LayoutLMForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMForTokenClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = torch.tensor([token_boxes])
<span class="hljs-meta">&gt;&gt;&gt; </span>token_labels = torch.tensor([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># batch size of 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids,
<span class="hljs-meta">... </span>    bbox=bbox,
<span class="hljs-meta">... </span>    attention_mask=attention_mask,
<span class="hljs-meta">... </span>    token_type_ids=token_type_ids,
<span class="hljs-meta">... </span>    labels=token_labels,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function nb(F){let d,b;return d=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBMYXlvdXRMTUZvclF1ZXN0aW9uQW5zd2VyaW5nJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9h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VuY2VfaWRzKDApJTJDJTIwZW5jb2Rpbmcud29yZF9pZHMoMCkpJTNBJTBBJTIwJTIwJTIwJTIwaWYlMjBzJTIwJTNEJTNEJTIwMSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJib3guYXBwZW5kKGJveGVzJTVCdyU1RCklMEElMjAlMjAlMjAlMjBlbGlmJTIwaSUyMCUzRCUzRCUyMHRva2VuaXplci5zZXBfdG9rZW5faWQlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiYm94LmFwcGVuZCglNUIxMDAwJTVEJTIwKiUyMDQpJTBBJTIwJTIwJTIwJTIwZWxzZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJib3guYXBwZW5kKCU1QjAlNUQlMjAqJTIwNCklMEFlbmNvZGluZyU1QiUyMmJib3glMjIlNUQlMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCYmJveCU1RCklMEElMEF3b3JkX2lkcyUyMCUzRCUyMGVuY29kaW5nLndvcmRfaWRzKDApJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqZW5jb2RpbmcpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXN0YXJ0X3Njb3JlcyUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzJTBBZW5kX3Njb3JlcyUyMCUzRCUyMG91dHB1dHMuZW5kX2xvZ2l0cyUwQXN0YXJ0JTJDJTIwZW5kJTIwJTNEJTIwd29yZF9pZHMlNUJzdGFydF9zY29yZXMuYXJnbWF4KC0xKSU1RCUyQyUyMHdvcmRfaWRzJTVCZW5kX3Njb3Jlcy5hcmdtYXgoLTEpJTVEJTBBcHJpbnQoJTIyJTIwJTIyLmpvaW4od29yZHMlNUJzdGFydCUyMCUzQSUyMGVuZCUyMCUyQiUyMDElNUQpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, LayoutLMForQuestionAnswering
<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><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;impira/layoutlm-document-qa&quot;</span>, add_prefix_space=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = LayoutLMForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;impira/layoutlm-document-qa&quot;</span>, revision=<span class="hljs-string">&quot;1e3ebac&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;nielsr/funsd&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>example = dataset[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;what&#x27;s his name?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>words = example[<span class="hljs-string">&quot;words&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>boxes = example[<span class="hljs-string">&quot;bboxes&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(
<span class="hljs-meta">... </span>    question.split(), words, is_split_into_words=<span class="hljs-literal">True</span>, return_token_type_ids=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> i, s, w <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(encoding.input_ids[<span class="hljs-number">0</span>], encoding.sequence_ids(<span class="hljs-number">0</span>), encoding.word_ids(<span class="hljs-number">0</span>)):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> s == <span class="hljs-number">1</span>:
<span class="hljs-meta">... </span>        bbox.append(boxes[w])
<span class="hljs-meta">... </span>    <span class="hljs-keyword">elif</span> i == tokenizer.sep_token_id:
<span class="hljs-meta">... </span>        bbox.append([<span class="hljs-number">1000</span>] * <span class="hljs-number">4</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>        bbox.append([<span class="hljs-number">0</span>] * <span class="hljs-number">4</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding[<span class="hljs-string">&quot;bbox&quot;</span>] = torch.tensor([bbox])

<span class="hljs-meta">&gt;&gt;&gt; </span>word_ids = encoding.word_ids(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>start_scores = outputs.start_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>end_scores = outputs.end_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>start, end = word_ids[start_scores.argmax(-<span class="hljs-number">1</span>)], word_ids[end_scores.argmax(-<span class="hljs-number">1</span>)]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot; &quot;</span>.join(words[start : end + <span class="hljs-number">1</span>]))
M. Hamann P. Harper, P. Martinez`}}),{c(){w(d.$$.fragment)},l(f){k(d.$$.fragment,f)},m(f,g){v(d,f,g),b=!0},p:gt,i(f){b||(L(d.$$.fragment,f),b=!0)},o(f){j(d.$$.fragment,f),b=!1},d(f){U(d,f)}}}function sb(F){let d,b,f,g,M,i,h,E,Le,ye,W,_e,G,T,he,R,je,me,D,Me,se,X,le,Ue,S,be,oe,Z,Je,ie,ae,$,I,de,P,ce,Ce,H,Ee,pe,z,ue,O,$e,Te,Q,Fe,we,A,fe,Y,ke,ee,x,ve,N,B,Ie;return{c(){d=a("p"),b=n("TensorFlow models and layers in "),f=a("code"),g=n("transformers"),M=n(" accept two formats as input:"),i=c(),h=a("ul"),E=a("li"),Le=n("having all inputs as keyword arguments (like PyTorch models), or"),ye=c(),W=a("li"),_e=n("having all inputs as a list, tuple or dict in the first positional argument."),G=c(),T=a("p"),he=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=a("code"),je=n("model.fit()"),me=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=a("code"),Me=n("model.fit()"),se=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),X=a("code"),le=n("fit()"),Ue=n(" and "),S=a("code"),be=n("predict()"),oe=n(`, such as when creating your own layers or models with
the Keras `),Z=a("code"),Je=n("Functional"),ie=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),ae=c(),$=a("ul"),I=a("li"),de=n("a single Tensor with "),P=a("code"),ce=n("input_ids"),Ce=n(" only and nothing else: "),H=a("code"),Ee=n("model(input_ids)"),pe=c(),z=a("li"),ue=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=a("code"),$e=n("model([input_ids, attention_mask])"),Te=n(" or "),Q=a("code"),Fe=n("model([input_ids, attention_mask, token_type_ids])"),we=c(),A=a("li"),fe=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=a("code"),ke=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ee=c(),x=a("p"),ve=n(`Note that when creating models and layers with
`),N=a("a"),B=n("subclassing"),Ie=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(_){d=r(_,"P",{});var J=l(d);b=s(J,"TensorFlow models and layers in "),f=r(J,"CODE",{});var Ve=l(f);g=s(Ve,"transformers"),Ve.forEach(t),M=s(J," accept two formats as input:"),J.forEach(t),i=p(_),h=r(_,"UL",{});var te=l(h);E=r(te,"LI",{});var We=l(E);Le=s(We,"having all inputs as keyword arguments (like PyTorch models), or"),We.forEach(t),ye=p(te),W=r(te,"LI",{});var Qe=l(W);_e=s(Qe,"having all inputs as a list, tuple or dict in the first positional argument."),Qe.forEach(t),te.forEach(t),G=p(_),T=r(_,"P",{});var C=l(T);he=s(C,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=r(C,"CODE",{});var Be=l(R);je=s(Be,"model.fit()"),Be.forEach(t),me=s(C,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=r(C,"CODE",{});var Ge=l(D);Me=s(Ge,"model.fit()"),Ge.forEach(t),se=s(C,` supports! If, however, you want to use the second
format outside of Keras methods like `),X=r(C,"CODE",{});var xe=l(X);le=s(xe,"fit()"),xe.forEach(t),Ue=s(C," and "),S=r(C,"CODE",{});var De=l(S);be=s(De,"predict()"),De.forEach(t),oe=s(C,`, such as when creating your own layers or models with
the Keras `),Z=r(C,"CODE",{});var Xe=l(Z);Je=s(Xe,"Functional"),Xe.forEach(t),ie=s(C,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),C.forEach(t),ae=p(_),$=r(_,"UL",{});var q=l($);I=r(q,"LI",{});var K=l(I);de=s(K,"a single Tensor with "),P=r(K,"CODE",{});var Se=l(P);ce=s(Se,"input_ids"),Se.forEach(t),Ce=s(K," only and nothing else: "),H=r(K,"CODE",{});var Ae=l(H);Ee=s(Ae,"model(input_ids)"),Ae.forEach(t),K.forEach(t),pe=p(q),z=r(q,"LI",{});var V=l(z);ue=s(V,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=r(V,"CODE",{});var Re=l(O);$e=s(Re,"model([input_ids, attention_mask])"),Re.forEach(t),Te=s(V," or "),Q=r(V,"CODE",{});var ge=l(Q);Fe=s(ge,"model([input_ids, attention_mask, token_type_ids])"),ge.forEach(t),V.forEach(t),we=p(q),A=r(q,"LI",{});var ze=l(A);fe=s(ze,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=r(ze,"CODE",{});var qe=l(Y);ke=s(qe,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),qe.forEach(t),ze.forEach(t),q.forEach(t),ee=p(_),x=r(_,"P",{});var re=l(x);ve=s(re,`Note that when creating models and layers with
`),N=r(re,"A",{href:!0,rel:!0});var Pe=l(N);B=s(Pe,"subclassing"),Pe.forEach(t),Ie=s(re,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),re.forEach(t),this.h()},h(){u(N,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(N,"rel","nofollow")},m(_,J){m(_,d,J),e(d,b),e(d,f),e(f,g),e(d,M),m(_,i,J),m(_,h,J),e(h,E),e(E,Le),e(h,ye),e(h,W),e(W,_e),m(_,G,J),m(_,T,J),e(T,he),e(T,R),e(R,je),e(T,me),e(T,D),e(D,Me),e(T,se),e(T,X),e(X,le),e(T,Ue),e(T,S),e(S,be),e(T,oe),e(T,Z),e(Z,Je),e(T,ie),m(_,ae,J),m(_,$,J),e($,I),e(I,de),e(I,P),e(P,ce),e(I,Ce),e(I,H),e(H,Ee),e($,pe),e($,z),e(z,ue),e(z,O),e(O,$e),e(z,Te),e(z,Q),e(Q,Fe),e($,we),e($,A),e(A,fe),e(A,Y),e(Y,ke),m(_,ee,J),m(_,x,J),e(x,ve),e(x,N),e(N,B),e(x,Ie)},d(_){_&&t(d),_&&t(i),_&&t(h),_&&t(G),_&&t(T),_&&t(ae),_&&t($),_&&t(ee),_&&t(x)}}}function ab(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing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iUyMGNscyUyMCUyQiUyMHNlcCUyMHRva2VucyUwQXRva2VuX2JveGVzJTIwJTNEJTIwJTVCJTVCMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCU1RCU1RCUyMCUyQiUyMHRva2VuX2JveGVzJTIwJTJCJTIwJTVCJTVCMTAwMCUyQyUyMDEwMDAlMkMlMjAxMDAwJTJDJTIwMTAwMCU1RCU1RCUwQSUwQWVuY29kaW5nJTIwJTNEJTIwdG9rZW5pemVyKCUyMiUyMCUyMi5qb2luKHdvcmRzKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBaW5wdXRfaWRzJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFhdHRlbnRpb25fbWFzayUyMCUzRCUyMGVuY29kaW5nJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlNUQlMEF0b2tlbl90eXBlX2lkcyUyMCUzRCUyMGVuY29kaW5nJTVCJTIydG9rZW5fdHlwZV9pZHMlMjIlNUQlMEFiYm94JTIwJTNEJTIwdGYuY29udmVydF90b190ZW5zb3IoJTVCdG9rZW5fYm94ZXMlNUQpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGJib3glM0RiYm94JTJDJTIwYXR0ZW50aW9uX21hc2slM0RhdHRlbnRpb25fbWFzayUyQyUyMHRva2VuX3R5cGVfaWRzJTNEdG9rZW5fdHlwZV9pZHMlMEEpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFLayoutLMModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFLayoutLMModel.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = tf.convert_to_tensor([token_boxes])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids, bbox=bbox, attention_mask=attention_mask, token_type_ids=token_type_ids
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function lb(F){let d,b,f,g,M,i,h,E,Le,ye,W,_e,G,T,he,R,je,me,D,Me,se,X,le,Ue,S,be,oe,Z,Je,ie,ae,$,I,de,P,ce,Ce,H,Ee,pe,z,ue,O,$e,Te,Q,Fe,we,A,fe,Y,ke,ee,x,ve,N,B,Ie;return{c(){d=a("p"),b=n("TensorFlow models and layers in "),f=a("code"),g=n("transformers"),M=n(" accept two formats as input:"),i=c(),h=a("ul"),E=a("li"),Le=n("having all inputs as keyword arguments (like PyTorch models), or"),ye=c(),W=a("li"),_e=n("having all inputs as a list, tuple or dict in the first positional argument."),G=c(),T=a("p"),he=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=a("code"),je=n("model.fit()"),me=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=a("code"),Me=n("model.fit()"),se=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),X=a("code"),le=n("fit()"),Ue=n(" and "),S=a("code"),be=n("predict()"),oe=n(`, such as when creating your own layers or models with
the Keras `),Z=a("code"),Je=n("Functional"),ie=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),ae=c(),$=a("ul"),I=a("li"),de=n("a single Tensor with "),P=a("code"),ce=n("input_ids"),Ce=n(" only and nothing else: "),H=a("code"),Ee=n("model(input_ids)"),pe=c(),z=a("li"),ue=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=a("code"),$e=n("model([input_ids, attention_mask])"),Te=n(" or "),Q=a("code"),Fe=n("model([input_ids, attention_mask, token_type_ids])"),we=c(),A=a("li"),fe=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=a("code"),ke=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ee=c(),x=a("p"),ve=n(`Note that when creating models and layers with
`),N=a("a"),B=n("subclassing"),Ie=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(_){d=r(_,"P",{});var J=l(d);b=s(J,"TensorFlow models and layers in "),f=r(J,"CODE",{});var Ve=l(f);g=s(Ve,"transformers"),Ve.forEach(t),M=s(J," accept two formats as input:"),J.forEach(t),i=p(_),h=r(_,"UL",{});var te=l(h);E=r(te,"LI",{});var We=l(E);Le=s(We,"having all inputs as keyword arguments (like PyTorch models), or"),We.forEach(t),ye=p(te),W=r(te,"LI",{});var Qe=l(W);_e=s(Qe,"having all inputs as a list, tuple or dict in the first positional argument."),Qe.forEach(t),te.forEach(t),G=p(_),T=r(_,"P",{});var C=l(T);he=s(C,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=r(C,"CODE",{});var Be=l(R);je=s(Be,"model.fit()"),Be.forEach(t),me=s(C,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=r(C,"CODE",{});var Ge=l(D);Me=s(Ge,"model.fit()"),Ge.forEach(t),se=s(C,` supports! If, however, you want to use the second
format outside of Keras methods like `),X=r(C,"CODE",{});var xe=l(X);le=s(xe,"fit()"),xe.forEach(t),Ue=s(C," and "),S=r(C,"CODE",{});var De=l(S);be=s(De,"predict()"),De.forEach(t),oe=s(C,`, such as when creating your own layers or models with
the Keras `),Z=r(C,"CODE",{});var Xe=l(Z);Je=s(Xe,"Functional"),Xe.forEach(t),ie=s(C,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),C.forEach(t),ae=p(_),$=r(_,"UL",{});var q=l($);I=r(q,"LI",{});var K=l(I);de=s(K,"a single Tensor with "),P=r(K,"CODE",{});var Se=l(P);ce=s(Se,"input_ids"),Se.forEach(t),Ce=s(K," only and nothing else: "),H=r(K,"CODE",{});var Ae=l(H);Ee=s(Ae,"model(input_ids)"),Ae.forEach(t),K.forEach(t),pe=p(q),z=r(q,"LI",{});var V=l(z);ue=s(V,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=r(V,"CODE",{});var Re=l(O);$e=s(Re,"model([input_ids, attention_mask])"),Re.forEach(t),Te=s(V," or "),Q=r(V,"CODE",{});var ge=l(Q);Fe=s(ge,"model([input_ids, attention_mask, token_type_ids])"),ge.forEach(t),V.forEach(t),we=p(q),A=r(q,"LI",{});var ze=l(A);fe=s(ze,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=r(ze,"CODE",{});var qe=l(Y);ke=s(qe,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),qe.forEach(t),ze.forEach(t),q.forEach(t),ee=p(_),x=r(_,"P",{});var re=l(x);ve=s(re,`Note that when creating models and layers with
`),N=r(re,"A",{href:!0,rel:!0});var Pe=l(N);B=s(Pe,"subclassing"),Pe.forEach(t),Ie=s(re,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),re.forEach(t),this.h()},h(){u(N,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(N,"rel","nofollow")},m(_,J){m(_,d,J),e(d,b),e(d,f),e(f,g),e(d,M),m(_,i,J),m(_,h,J),e(h,E),e(E,Le),e(h,ye),e(h,W),e(W,_e),m(_,G,J),m(_,T,J),e(T,he),e(T,R),e(R,je),e(T,me),e(T,D),e(D,Me),e(T,se),e(T,X),e(X,le),e(T,Ue),e(T,S),e(S,be),e(T,oe),e(T,Z),e(Z,Je),e(T,ie),m(_,ae,J),m(_,$,J),e($,I),e(I,de),e(I,P),e(P,ce),e(I,Ce),e(I,H),e(H,Ee),e($,pe),e($,z),e(z,ue),e(z,O),e(O,$e),e(z,Te),e(z,Q),e(Q,Fe),e($,we),e($,A),e(A,fe),e(A,Y),e(Y,ke),m(_,ee,J),m(_,x,J),e(x,ve),e(x,N),e(N,B),e(x,Ie)},d(_){_&&t(d),_&&t(i),_&&t(h),_&&t(G),_&&t(T),_&&t(ae),_&&t($),_&&t(ee),_&&t(x)}}}function ib(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function db(F){let d,b,f,g,M;return g=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkxheW91dExNRm9yTWFza2VkTE0lMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3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MlM0QlMjJ0ZiUyMiklMEFpbnB1dF9pZHMlMjAlM0QlMjBlbmNvZGluZyU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQWF0dGVudGlvbl9tYXNrJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJhdHRlbnRpb25fbWFzayUyMiU1RCUwQXRva2VuX3R5cGVfaWRzJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJ0b2tlbl90eXBlX2lkcyUyMiU1RCUwQWJib3glMjAlM0QlMjB0Zi5jb252ZXJ0X3RvX3RlbnNvciglNUJ0b2tlbl9ib3hlcyU1RCklMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMjB3b3JsZCUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGJib3glM0RiYm94JTJDJTBBJTIwJTIwJTIwJTIwYXR0ZW50aW9uX21hc2slM0RhdHRlbnRpb25fbWFzayUyQyUwQSUyMCUyMCUyMCUyMHRva2VuX3R5cGVfaWRzJTNEdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjBsYWJlbHMlM0RsYWJlbHMlMkMlMEEpJTBBJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFLayoutLMForMaskedLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFLayoutLMForMaskedLM.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;[MASK]&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = tf.convert_to_tensor([token_boxes])

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;Hello world&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids,
<span class="hljs-meta">... </span>    bbox=bbox,
<span class="hljs-meta">... </span>    attention_mask=attention_mask,
<span class="hljs-meta">... </span>    token_type_ids=token_type_ids,
<span class="hljs-meta">... </span>    labels=labels,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function cb(F){let d,b,f,g,M,i,h,E,Le,ye,W,_e,G,T,he,R,je,me,D,Me,se,X,le,Ue,S,be,oe,Z,Je,ie,ae,$,I,de,P,ce,Ce,H,Ee,pe,z,ue,O,$e,Te,Q,Fe,we,A,fe,Y,ke,ee,x,ve,N,B,Ie;return{c(){d=a("p"),b=n("TensorFlow models and layers in "),f=a("code"),g=n("transformers"),M=n(" accept two formats as input:"),i=c(),h=a("ul"),E=a("li"),Le=n("having all inputs as keyword arguments (like PyTorch models), or"),ye=c(),W=a("li"),_e=n("having all inputs as a list, tuple or dict in the first positional argument."),G=c(),T=a("p"),he=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=a("code"),je=n("model.fit()"),me=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=a("code"),Me=n("model.fit()"),se=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),X=a("code"),le=n("fit()"),Ue=n(" and "),S=a("code"),be=n("predict()"),oe=n(`, such as when creating your own layers or models with
the Keras `),Z=a("code"),Je=n("Functional"),ie=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),ae=c(),$=a("ul"),I=a("li"),de=n("a single Tensor with "),P=a("code"),ce=n("input_ids"),Ce=n(" only and nothing else: "),H=a("code"),Ee=n("model(input_ids)"),pe=c(),z=a("li"),ue=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=a("code"),$e=n("model([input_ids, attention_mask])"),Te=n(" or "),Q=a("code"),Fe=n("model([input_ids, attention_mask, token_type_ids])"),we=c(),A=a("li"),fe=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=a("code"),ke=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ee=c(),x=a("p"),ve=n(`Note that when creating models and layers with
`),N=a("a"),B=n("subclassing"),Ie=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(_){d=r(_,"P",{});var J=l(d);b=s(J,"TensorFlow models and layers in "),f=r(J,"CODE",{});var Ve=l(f);g=s(Ve,"transformers"),Ve.forEach(t),M=s(J," accept two formats as input:"),J.forEach(t),i=p(_),h=r(_,"UL",{});var te=l(h);E=r(te,"LI",{});var We=l(E);Le=s(We,"having all inputs as keyword arguments (like PyTorch models), or"),We.forEach(t),ye=p(te),W=r(te,"LI",{});var Qe=l(W);_e=s(Qe,"having all inputs as a list, tuple or dict in the first positional argument."),Qe.forEach(t),te.forEach(t),G=p(_),T=r(_,"P",{});var C=l(T);he=s(C,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=r(C,"CODE",{});var Be=l(R);je=s(Be,"model.fit()"),Be.forEach(t),me=s(C,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=r(C,"CODE",{});var Ge=l(D);Me=s(Ge,"model.fit()"),Ge.forEach(t),se=s(C,` supports! If, however, you want to use the second
format outside of Keras methods like `),X=r(C,"CODE",{});var xe=l(X);le=s(xe,"fit()"),xe.forEach(t),Ue=s(C," and "),S=r(C,"CODE",{});var De=l(S);be=s(De,"predict()"),De.forEach(t),oe=s(C,`, such as when creating your own layers or models with
the Keras `),Z=r(C,"CODE",{});var Xe=l(Z);Je=s(Xe,"Functional"),Xe.forEach(t),ie=s(C,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),C.forEach(t),ae=p(_),$=r(_,"UL",{});var q=l($);I=r(q,"LI",{});var K=l(I);de=s(K,"a single Tensor with "),P=r(K,"CODE",{});var Se=l(P);ce=s(Se,"input_ids"),Se.forEach(t),Ce=s(K," only and nothing else: "),H=r(K,"CODE",{});var Ae=l(H);Ee=s(Ae,"model(input_ids)"),Ae.forEach(t),K.forEach(t),pe=p(q),z=r(q,"LI",{});var V=l(z);ue=s(V,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=r(V,"CODE",{});var Re=l(O);$e=s(Re,"model([input_ids, attention_mask])"),Re.forEach(t),Te=s(V," or "),Q=r(V,"CODE",{});var ge=l(Q);Fe=s(ge,"model([input_ids, attention_mask, token_type_ids])"),ge.forEach(t),V.forEach(t),we=p(q),A=r(q,"LI",{});var ze=l(A);fe=s(ze,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=r(ze,"CODE",{});var qe=l(Y);ke=s(qe,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),qe.forEach(t),ze.forEach(t),q.forEach(t),ee=p(_),x=r(_,"P",{});var re=l(x);ve=s(re,`Note that when creating models and layers with
`),N=r(re,"A",{href:!0,rel:!0});var Pe=l(N);B=s(Pe,"subclassing"),Pe.forEach(t),Ie=s(re,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),re.forEach(t),this.h()},h(){u(N,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(N,"rel","nofollow")},m(_,J){m(_,d,J),e(d,b),e(d,f),e(f,g),e(d,M),m(_,i,J),m(_,h,J),e(h,E),e(E,Le),e(h,ye),e(h,W),e(W,_e),m(_,G,J),m(_,T,J),e(T,he),e(T,R),e(R,je),e(T,me),e(T,D),e(D,Me),e(T,se),e(T,X),e(X,le),e(T,Ue),e(T,S),e(S,be),e(T,oe),e(T,Z),e(Z,Je),e(T,ie),m(_,ae,J),m(_,$,J),e($,I),e(I,de),e(I,P),e(P,ce),e(I,Ce),e(I,H),e(H,Ee),e($,pe),e($,z),e(z,ue),e(z,O),e(O,$e),e(z,Te),e(z,Q),e(Q,Fe),e($,we),e($,A),e(A,fe),e(A,Y),e(Y,ke),m(_,ee,J),m(_,x,J),e(x,ve),e(x,N),e(N,B),e(x,Ie)},d(_){_&&t(d),_&&t(i),_&&t(h),_&&t(G),_&&t(T),_&&t(ae),_&&t($),_&&t(ee),_&&t(x)}}}function pb(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function ub(F){let d,b,f,g,M;return g=new it({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkxheW91dExNRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQWltcG9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MCUyQyUyMDEwMDAlNUQlNUQlMEElMEFlbmNvZGluZyUyMCUzRCUyMHRva2VuaXplciglMjIlMjAlMjIuam9pbih3b3JkcyklMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQWlucHV0X2lkcyUyMCUzRCUyMGVuY29kaW5nJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBYXR0ZW50aW9uX21hc2slMjAlM0QlMjBlbmNvZGluZyU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTVEJTBBdG9rZW5fdHlwZV9pZHMlMjAlM0QlMjBlbmNvZGluZyU1QiUyMnRva2VuX3R5cGVfaWRzJTIyJTVEJTBBYmJveCUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKCU1QnRva2VuX2JveGVzJTVEKSUwQXNlcXVlbmNlX2xhYmVsJTIwJTNEJTIwdGYuY29udmVydF90b190ZW5zb3IoJTVCMSU1RCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoJTBBJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTBBJTIwJTIwJTIwJTIwYmJveCUzRGJib3glMkMlMEElMjAlMjAlMjAlMjBhdHRlbnRpb25fbWFzayUzRGF0dGVudGlvbl9tYXNrJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5fdHlwZV9pZHMlM0R0b2tlbl90eXBlX2lkcyUyQyUwQSUyMCUyMCUyMCUyMGxhYmVscyUzRHNlcXVlbmNlX2xhYmVsJTJDJTBBKSUwQSUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3MlMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFLayoutLMForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFLayoutLMForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = tf.convert_to_tensor([token_boxes])
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence_label = tf.convert_to_tensor([<span class="hljs-number">1</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids,
<span class="hljs-meta">... </span>    bbox=bbox,
<span class="hljs-meta">... </span>    attention_mask=attention_mask,
<span class="hljs-meta">... </span>    token_type_ids=token_type_ids,
<span class="hljs-meta">... </span>    labels=sequence_label,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function hb(F){let d,b,f,g,M,i,h,E,Le,ye,W,_e,G,T,he,R,je,me,D,Me,se,X,le,Ue,S,be,oe,Z,Je,ie,ae,$,I,de,P,ce,Ce,H,Ee,pe,z,ue,O,$e,Te,Q,Fe,we,A,fe,Y,ke,ee,x,ve,N,B,Ie;return{c(){d=a("p"),b=n("TensorFlow models and layers in "),f=a("code"),g=n("transformers"),M=n(" accept two formats as input:"),i=c(),h=a("ul"),E=a("li"),Le=n("having all inputs as keyword arguments (like PyTorch models), or"),ye=c(),W=a("li"),_e=n("having all inputs as a list, tuple or dict in the first positional argument."),G=c(),T=a("p"),he=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=a("code"),je=n("model.fit()"),me=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=a("code"),Me=n("model.fit()"),se=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),X=a("code"),le=n("fit()"),Ue=n(" and "),S=a("code"),be=n("predict()"),oe=n(`, such as when creating your own layers or models with
the Keras `),Z=a("code"),Je=n("Functional"),ie=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),ae=c(),$=a("ul"),I=a("li"),de=n("a single Tensor with "),P=a("code"),ce=n("input_ids"),Ce=n(" only and nothing else: "),H=a("code"),Ee=n("model(input_ids)"),pe=c(),z=a("li"),ue=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=a("code"),$e=n("model([input_ids, attention_mask])"),Te=n(" or "),Q=a("code"),Fe=n("model([input_ids, attention_mask, token_type_ids])"),we=c(),A=a("li"),fe=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=a("code"),ke=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ee=c(),x=a("p"),ve=n(`Note that when creating models and layers with
`),N=a("a"),B=n("subclassing"),Ie=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(_){d=r(_,"P",{});var J=l(d);b=s(J,"TensorFlow models and layers in "),f=r(J,"CODE",{});var Ve=l(f);g=s(Ve,"transformers"),Ve.forEach(t),M=s(J," accept two formats as input:"),J.forEach(t),i=p(_),h=r(_,"UL",{});var te=l(h);E=r(te,"LI",{});var We=l(E);Le=s(We,"having all inputs as keyword arguments (like PyTorch models), or"),We.forEach(t),ye=p(te),W=r(te,"LI",{});var Qe=l(W);_e=s(Qe,"having all inputs as a list, tuple or dict in the first positional argument."),Qe.forEach(t),te.forEach(t),G=p(_),T=r(_,"P",{});var C=l(T);he=s(C,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=r(C,"CODE",{});var Be=l(R);je=s(Be,"model.fit()"),Be.forEach(t),me=s(C,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=r(C,"CODE",{});var Ge=l(D);Me=s(Ge,"model.fit()"),Ge.forEach(t),se=s(C,` supports! If, however, you want to use the second
format outside of Keras methods like `),X=r(C,"CODE",{});var xe=l(X);le=s(xe,"fit()"),xe.forEach(t),Ue=s(C," and "),S=r(C,"CODE",{});var De=l(S);be=s(De,"predict()"),De.forEach(t),oe=s(C,`, such as when creating your own layers or models with
the Keras `),Z=r(C,"CODE",{});var Xe=l(Z);Je=s(Xe,"Functional"),Xe.forEach(t),ie=s(C,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),C.forEach(t),ae=p(_),$=r(_,"UL",{});var q=l($);I=r(q,"LI",{});var K=l(I);de=s(K,"a single Tensor with "),P=r(K,"CODE",{});var Se=l(P);ce=s(Se,"input_ids"),Se.forEach(t),Ce=s(K," only and nothing else: "),H=r(K,"CODE",{});var Ae=l(H);Ee=s(Ae,"model(input_ids)"),Ae.forEach(t),K.forEach(t),pe=p(q),z=r(q,"LI",{});var V=l(z);ue=s(V,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=r(V,"CODE",{});var Re=l(O);$e=s(Re,"model([input_ids, attention_mask])"),Re.forEach(t),Te=s(V," or "),Q=r(V,"CODE",{});var ge=l(Q);Fe=s(ge,"model([input_ids, attention_mask, token_type_ids])"),ge.forEach(t),V.forEach(t),we=p(q),A=r(q,"LI",{});var ze=l(A);fe=s(ze,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=r(ze,"CODE",{});var qe=l(Y);ke=s(qe,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),qe.forEach(t),ze.forEach(t),q.forEach(t),ee=p(_),x=r(_,"P",{});var re=l(x);ve=s(re,`Note that when creating models and layers with
`),N=r(re,"A",{href:!0,rel:!0});var Pe=l(N);B=s(Pe,"subclassing"),Pe.forEach(t),Ie=s(re,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),re.forEach(t),this.h()},h(){u(N,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(N,"rel","nofollow")},m(_,J){m(_,d,J),e(d,b),e(d,f),e(f,g),e(d,M),m(_,i,J),m(_,h,J),e(h,E),e(E,Le),e(h,ye),e(h,W),e(W,_e),m(_,G,J),m(_,T,J),e(T,he),e(T,R),e(R,je),e(T,me),e(T,D),e(D,Me),e(T,se),e(T,X),e(X,le),e(T,Ue),e(T,S),e(S,be),e(T,oe),e(T,Z),e(Z,Je),e(T,ie),m(_,ae,J),m(_,$,J),e($,I),e(I,de),e(I,P),e(P,ce),e(I,Ce),e(I,H),e(H,Ee),e($,pe),e($,z),e(z,ue),e(z,O),e(O,$e),e(z,Te),e(z,Q),e(Q,Fe),e($,we),e($,A),e(A,fe),e(A,Y),e(Y,ke),m(_,ee,J),m(_,x,J),e(x,ve),e(x,N),e(N,B),e(x,Ie)},d(_){_&&t(d),_&&t(i),_&&t(h),_&&t(G),_&&t(T),_&&t(ae),_&&t($),_&&t(ee),_&&t(x)}}}function mb(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(i,h){m(i,d,h),e(d,b),e(d,f),e(f,g),e(d,M)},d(i){i&&t(d)}}}function fb(F){let d,b,f,g,M;return g=new it({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlME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lMkIlMjB0b2tlbl9ib3hlcyUyMCUyQiUyMCU1QiU1QjEwMDAlMkMlMjAxMDAwJTJDJTIwMTAwMCUyQyUyMDEwMDAlNUQlNUQlMEElMEFlbmNvZGluZyUyMCUzRCUyMHRva2VuaXplciglMjIlMjAlMjIuam9pbih3b3JkcyklMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQWlucHV0X2lkcyUyMCUzRCUyMGVuY29kaW5nJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBYXR0ZW50aW9uX21hc2slMjAlM0QlMjBlbmNvZGluZyU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTVEJTBBdG9rZW5fdHlwZV9pZHMlMjAlM0QlMjBlbmNvZGluZyU1QiUyMnRva2VuX3R5cGVfaWRzJTIyJTVEJTBBYmJveCUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKCU1QnRva2VuX2JveGVzJTVEKSUwQXRva2VuX2xhYmVscyUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKCU1QjElMkMlMjAxJTJDJTIwMCUyQyUyMDAlNUQpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGJib3glM0RiYm94JTJDJTBBJTIwJTIwJTIwJTIwYXR0ZW50aW9uX21hc2slM0RhdHRlbnRpb25fbWFzayUyQyUwQSUyMCUyMCUyMCUyMHRva2VuX3R5cGVfaWRzJTNEdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjBsYWJlbHMlM0R0b2tlbl9sYWJlbHMlMkMlMEEpJTBBJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQWxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFLayoutLMForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFLayoutLMForTokenClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlm-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;Hello&quot;</span>, <span class="hljs-string">&quot;world&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>normalized_word_boxes = [<span class="hljs-number">637</span>, <span class="hljs-number">773</span>, <span class="hljs-number">693</span>, <span class="hljs-number">782</span>], [<span class="hljs-number">698</span>, <span class="hljs-number">773</span>, <span class="hljs-number">733</span>, <span class="hljs-number">782</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> word, box <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, normalized_word_boxes):
<span class="hljs-meta">... </span>    word_tokens = tokenizer.tokenize(word)
<span class="hljs-meta">... </span>    token_boxes.extend([box] * <span class="hljs-built_in">len</span>(word_tokens))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add bounding boxes of cls + sep tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>token_boxes = [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]] + token_boxes + [[<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot; &quot;</span>.join(words), return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = encoding[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = encoding[<span class="hljs-string">&quot;attention_mask&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = encoding[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = tf.convert_to_tensor([token_boxes])
<span class="hljs-meta">&gt;&gt;&gt; </span>token_labels = tf.convert_to_tensor([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    input_ids=input_ids,
<span class="hljs-meta">... </span>    bbox=bbox,
<span class="hljs-meta">... </span>    attention_mask=attention_mask,
<span class="hljs-meta">... </span>    token_type_ids=token_type_ids,
<span class="hljs-meta">... </span>    labels=token_labels,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function gb(F){let d,b,f,g,M,i,h,E,Le,ye,W,_e,G,T,he,R,je,me,D,Me,se,X,le,Ue,S,be,oe,Z,Je,ie,ae,$,I,de,P,ce,Ce,H,Ee,pe,z,ue,O,$e,Te,Q,Fe,we,A,fe,Y,ke,ee,x,ve,N,B,Ie;return{c(){d=a("p"),b=n("TensorFlow models and layers in "),f=a("code"),g=n("transformers"),M=n(" accept two formats as input:"),i=c(),h=a("ul"),E=a("li"),Le=n("having all inputs as keyword arguments (like PyTorch models), or"),ye=c(),W=a("li"),_e=n("having all inputs as a list, tuple or dict in the first positional argument."),G=c(),T=a("p"),he=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=a("code"),je=n("model.fit()"),me=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=a("code"),Me=n("model.fit()"),se=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),X=a("code"),le=n("fit()"),Ue=n(" and "),S=a("code"),be=n("predict()"),oe=n(`, such as when creating your own layers or models with
the Keras `),Z=a("code"),Je=n("Functional"),ie=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),ae=c(),$=a("ul"),I=a("li"),de=n("a single Tensor with "),P=a("code"),ce=n("input_ids"),Ce=n(" only and nothing else: "),H=a("code"),Ee=n("model(input_ids)"),pe=c(),z=a("li"),ue=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=a("code"),$e=n("model([input_ids, attention_mask])"),Te=n(" or "),Q=a("code"),Fe=n("model([input_ids, attention_mask, token_type_ids])"),we=c(),A=a("li"),fe=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=a("code"),ke=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ee=c(),x=a("p"),ve=n(`Note that when creating models and layers with
`),N=a("a"),B=n("subclassing"),Ie=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(_){d=r(_,"P",{});var J=l(d);b=s(J,"TensorFlow models and layers in "),f=r(J,"CODE",{});var Ve=l(f);g=s(Ve,"transformers"),Ve.forEach(t),M=s(J," accept two formats as input:"),J.forEach(t),i=p(_),h=r(_,"UL",{});var te=l(h);E=r(te,"LI",{});var We=l(E);Le=s(We,"having all inputs as keyword arguments (like PyTorch models), or"),We.forEach(t),ye=p(te),W=r(te,"LI",{});var Qe=l(W);_e=s(Qe,"having all inputs as a list, tuple or dict in the first positional argument."),Qe.forEach(t),te.forEach(t),G=p(_),T=r(_,"P",{});var C=l(T);he=s(C,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),R=r(C,"CODE",{});var Be=l(R);je=s(Be,"model.fit()"),Be.forEach(t),me=s(C,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),D=r(C,"CODE",{});var Ge=l(D);Me=s(Ge,"model.fit()"),Ge.forEach(t),se=s(C,` supports! If, however, you want to use the second
format outside of Keras methods like `),X=r(C,"CODE",{});var xe=l(X);le=s(xe,"fit()"),xe.forEach(t),Ue=s(C," and "),S=r(C,"CODE",{});var De=l(S);be=s(De,"predict()"),De.forEach(t),oe=s(C,`, such as when creating your own layers or models with
the Keras `),Z=r(C,"CODE",{});var Xe=l(Z);Je=s(Xe,"Functional"),Xe.forEach(t),ie=s(C,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),C.forEach(t),ae=p(_),$=r(_,"UL",{});var q=l($);I=r(q,"LI",{});var K=l(I);de=s(K,"a single Tensor with "),P=r(K,"CODE",{});var Se=l(P);ce=s(Se,"input_ids"),Se.forEach(t),Ce=s(K," only and nothing else: "),H=r(K,"CODE",{});var Ae=l(H);Ee=s(Ae,"model(input_ids)"),Ae.forEach(t),K.forEach(t),pe=p(q),z=r(q,"LI",{});var V=l(z);ue=s(V,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),O=r(V,"CODE",{});var Re=l(O);$e=s(Re,"model([input_ids, attention_mask])"),Re.forEach(t),Te=s(V," or "),Q=r(V,"CODE",{});var ge=l(Q);Fe=s(ge,"model([input_ids, attention_mask, token_type_ids])"),ge.forEach(t),V.forEach(t),we=p(q),A=r(q,"LI",{});var ze=l(A);fe=s(ze,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),Y=r(ze,"CODE",{});var qe=l(Y);ke=s(qe,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),qe.forEach(t),ze.forEach(t),q.forEach(t),ee=p(_),x=r(_,"P",{});var re=l(x);ve=s(re,`Note that when creating models and layers with
`),N=r(re,"A",{href:!0,rel:!0});var Pe=l(N);B=s(Pe,"subclassing"),Pe.forEach(t),Ie=s(re,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),re.forEach(t),this.h()},h(){u(N,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(N,"rel","nofollow")},m(_,J){m(_,d,J),e(d,b),e(d,f),e(f,g),e(d,M),m(_,i,J),m(_,h,J),e(h,E),e(E,Le),e(h,ye),e(h,W),e(W,_e),m(_,G,J),m(_,T,J),e(T,he),e(T,R),e(R,je),e(T,me),e(T,D),e(D,Me),e(T,se),e(T,X),e(X,le),e(T,Ue),e(T,S),e(S,be),e(T,oe),e(T,Z),e(Z,Je),e(T,ie),m(_,ae,J),m(_,$,J),e($,I),e(I,de),e(I,P),e(P,ce),e(I,Ce),e(I,H),e(H,Ee),e($,pe),e($,z),e(z,ue),e(z,O),e(O,$e),e(z,Te),e(z,Q),e(Q,Fe),e($,we),e($,A),e(A,fe),e(A,Y),e(Y,ke),m(_,ee,J),m(_,x,J),e(x,ve),e(x,N),e(N,B),e(x,Ie)},d(_){_&&t(d),_&&t(i),_&&t(h),_&&t(G),_&&t(T),_&&t(ae),_&&t($),_&&t(ee),_&&t(x)}}}function yb(F){let d,b,f,g,M;return{c(){d=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),M=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(i){d=r(i,"P",{});var h=l(d);b=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var E=l(f);g=s(E,"Module"),E.forEach(t),M=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h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0JTJDJTIwZW5kJTIwJTNEJTIwd29yZF9pZHMlNUJ0Zi5tYXRoLmFyZ21heChzdGFydF9zY29yZXMlMkMlMjAtMSklNUIwJTVEJTVEJTJDJTIwd29yZF9pZHMlNUJ0Zi5tYXRoLmFyZ21heChlbmRfc2NvcmVzJTJDJTIwLTEpJTVCMCU1RCU1RCUwQXByaW50KCUyMiUyMCUyMi5qb2luKHdvcmRzJTVCc3RhcnQlMjAlM0ElMjBlbmQlMjAlMkIlMjAxJTVEKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFLayoutLMForQuestionAnswering
<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>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;impira/layoutlm-document-qa&quot;</span>, add_prefix_space=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFLayoutLMForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;impira/layoutlm-document-qa&quot;</span>, revision=<span class="hljs-string">&quot;1e3ebac&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;nielsr/funsd&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>example = dataset[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;what&#x27;s his name?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>words = example[<span class="hljs-string">&quot;words&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>boxes = example[<span class="hljs-string">&quot;bboxes&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(
<span class="hljs-meta">... </span>    question.split(), words, is_split_into_words=<span class="hljs-literal">True</span>, return_token_type_ids=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>bbox = []
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> i, s, w <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(encoding.input_ids[<span class="hljs-number">0</span>], encoding.sequence_ids(<span class="hljs-number">0</span>), encoding.word_ids(<span class="hljs-number">0</span>)):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> s == <span class="hljs-number">1</span>:
<span class="hljs-meta">... </span>        bbox.append(boxes[w])
<span class="hljs-meta">... </span>    <span class="hljs-keyword">elif</span> i == tokenizer.sep_token_id:
<span class="hljs-meta">... </span>        bbox.append([<span class="hljs-number">1000</span>] * <span class="hljs-number">4</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>        bbox.append([<span class="hljs-number">0</span>] * <span class="hljs-number">4</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding[<span class="hljs-string">&quot;bbox&quot;</span>] = tf.convert_to_tensor([bbox])

<span class="hljs-meta">&gt;&gt;&gt; </span>word_ids = encoding.word_ids(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>start_scores = outputs.start_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>end_scores = outputs.end_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>start, end = word_ids[tf.math.argmax(start_scores, -<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]], word_ids[tf.math.argmax(end_scores, -<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot; &quot;</span>.join(words[start : end + <span class="hljs-number">1</span>]))
M. Hamann P. Harper, P. Martinez`}}),{c(){d=a("p"),b=n("Examples:"),f=c(),w(g.$$.fragment)},l(i){d=r(i,"P",{});var h=l(d);b=s(h,"Examples:"),h.forEach(t),f=p(i),k(g.$$.fragment,i)},m(i,h){m(i,d,h),e(d,b),m(i,f,h),v(g,i,h),M=!0},p:gt,i(i){M||(L(g.$$.fragment,i),M=!0)},o(i){j(g.$$.fragment,i),M=!1},d(i){i&&t(d),i&&t(f),U(g,i)}}}function Mb(F){let d,b,f,g,M,i,h,E,Le,ye,W,_e,G,T,he,R,je,me,D,Me,se,X,le,Ue,S,be,oe,Z,Je,ie,ae,$,I,de,P,ce,Ce,H,Ee,pe,z,ue,O,$e,Te,Q,Fe,we,A,fe,Y,ke,ee,x,ve,N,B,Ie,_,J,Ve,te,We,Qe,C,Be,Ge,xe,De,Xe,q,K,Se,Ae,V,Re,ge,ze,qe,re,Pe,$r,rc,lc,ki,Cn,vi,Qt,bo,Fr,En,ic,Ir,dc,Li,za,cc,ji,$n,Ui,yt,zr,Fn,pc,In,uc,hc,mc,xr,zn,fc,xn,gc,yc,_c,Nr,Nn,Mc,qn,bc,Tc,wc,qr,xa,kc,Na,vc,Ji,An,Ci,To,Rn,Lc,Zn,jc,Uc,Jc,Ar,qa,Cc,Ei,Vn,$i,wo,Wn,Ec,Qn,$c,Fc,Ic,Rr,Aa,zc,Fi,Ra,Zr,xc,Ii,Za,Vr,Va,Nc,zi,Wa,qc,xi,Qa,Bn,Ac,Gn,Rc,Zc,Ni,Bt,ko,Wr,Dn,Vc,Qr,Wc,qi,ut,Xn,Qc,Gt,Bc,Ba,Gc,Dc,Sn,Xc,Sc,Pc,Dt,Hc,Ga,Oc,Yc,Da,Kc,ep,tp,vo,Ai,Xt,Lo,Br,Pn,op,Gr,np,Ri,Ze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DJTIwaGVpZ2h0KSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGludCgxMDAwJTIwKiUyMChiYm94JTVCMCU1RCUyMCUyRiUyMHdpZHRoKSklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnQoMTAwMCUyMColMjAoYmJveCU1QjElNUQlMjAlMkYlMjBoZWlnaHQpKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGludCgxMDAwJTIwKiUyMChiYm94JTVCMiU1RCUyMCUyRiUyMHdpZHRoKSklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnQoMTAwMCUyMColMjAoYmJveCU1QjMlNUQlMjAlMkYlMjBoZWlnaHQpKSUyQyUwQSUyMCUyMCUyMCUyMCU1RA==",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)),
    ]`}}),Cn=new it({props:{code:"ZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBJTIzJTIwRG9jdW1lbnQlMjBjYW4lMjBiZSUyMGElMjBwbmclMkMlMjBqcGclMkMlMjBldGMuJTIwUERGcyUyMG11c3QlMjBiZSUyMGNvbnZlcnRlZCUyMHRvJTIwaW1hZ2VzLiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihuYW1lX29mX3lvdXJfZG9jdW1lbnQpLmNvbnZlcnQoJTIyUkdCJTIyKSUwQSUwQXdpZHRoJTJDJTIwaGVpZ2h0JTIwJTNEJTIwaW1hZ2Uuc2l6ZQ==",highlighted:`<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

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

width, height = image.size`}}),En=new ot({}),$n=new Hg({props:{pipeline:"document-question-answering"}}),An=new Hg({props:{pipeline:"text-classification"}}),Vn=new Hg({props:{pipeline:"token-classification"}}),Dn=new ot({}),Xn=new ne({props:{name:"class transformers.LayoutLMConfig",anchor:"transformers.LayoutLMConfig",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:"position_embedding_type",val:" = 'absolute'"},{name:"use_cache",val:" = True"},{name:"max_2d_position_embeddings",val:" = 1024"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the LayoutLM model. Defines the different tokens that can be represented by the
<em>inputs_ids</em> passed to the forward method of <a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMModel">LayoutLMModel</a>.`,name:"vocab_size"},{anchor:"transformers.LayoutLMConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.LayoutLMConfig.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.LayoutLMConfig.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.LayoutLMConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.LayoutLMConfig.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;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.LayoutLMConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.LayoutLMConfig.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.LayoutLMConfig.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.LayoutLMConfig.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 into <a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMModel">LayoutLMModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.LayoutLMConfig.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.LayoutLMConfig.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.LayoutLMConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The value used to pad input_ids.`,name:"pad_token_id"},{anchor:"transformers.LayoutLMConfig.position_embedding_type",description:`<strong>position_embedding_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;absolute&quot;</code>) &#x2014;
Type of position embedding. Choose one of <code>&quot;absolute&quot;</code>, <code>&quot;relative_key&quot;</code>, <code>&quot;relative_key_query&quot;</code>. For
positional embeddings use <code>&quot;absolute&quot;</code>. For more information on <code>&quot;relative_key&quot;</code>, please refer to
<a href="https://arxiv.org/abs/1803.02155" rel="nofollow">Self-Attention with Relative Position Representations (Shaw et al.)</a>.
For more information on <code>&quot;relative_key_query&quot;</code>, please refer to <em>Method 4</em> in <a href="https://arxiv.org/abs/2009.13658" rel="nofollow">Improve Transformer Models
with Better Relative Position Embeddings (Huang et al.)</a>.`,name:"position_embedding_type"},{anchor:"transformers.LayoutLMConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"},{anchor:"transformers.LayoutLMConfig.classifier_dropout",description:`<strong>classifier_dropout</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The dropout ratio for the classification head.`,name:"classifier_dropout"},{anchor:"transformers.LayoutLMConfig.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 used. Typically set this to something large
just in case (e.g., 1024).`,name:"max_2d_position_embeddings"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/configuration_layoutlm.py#L36"}}),vo=new ft({props:{anchor:"transformers.LayoutLMConfig.example",$$slots:{default:[DM]},$$scope:{ctx:F}}}),Pn=new ot({}),Hn=new ne({props:{name:"class transformers.LayoutLMTokenizer",anchor:"transformers.LayoutLMTokenizer",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:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.LayoutLMTokenizer.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.LayoutLMTokenizer.do_basic_tokenize",description:`<strong>do_basic_tokenize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to do basic tokenization before WordPiece.`,name:"do_basic_tokenize"},{anchor:"transformers.LayoutLMTokenizer.never_split",description:`<strong>never_split</strong> (<code>Iterable</code>, <em>optional</em>) &#x2014;
Collection of tokens which will never be split during tokenization. Only has an effect when
<code>do_basic_tokenize=True</code>`,name:"never_split"},{anchor:"transformers.LayoutLMTokenizer.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.LayoutLMTokenizer.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.LayoutLMTokenizer.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.LayoutLMTokenizer.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.LayoutLMTokenizer.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.LayoutLMTokenizer.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.</p>
<p>This should likely be deactivated for Japanese (see this
<a href="https://github.com/huggingface/transformers/issues/328" rel="nofollow">issue</a>).`,name:"tokenize_chinese_chars"},{anchor:"transformers.LayoutLMTokenizer.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 LayoutLM).`,name:"strip_accents"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm.py#L75"}}),Yn=new ne({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.LayoutLMTokenizer.build_inputs_with_special_tokens",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizer.build_inputs_with_special_tokens.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs to which the special tokens will be added.`,name:"token_ids_0"},{anchor:"transformers.LayoutLMTokenizer.build_inputs_with_special_tokens.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm.py#L207",returnDescription:`
<p>List of <a href="../glossary#input-ids">input IDs</a> with the appropriate special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),es=new ne({props:{name:"convert_tokens_to_string",anchor:"transformers.LayoutLMTokenizer.convert_tokens_to_string",parameters:[{name:"tokens",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm.py#L202"}}),ts=new ne({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.LayoutLMTokenizer.create_token_type_ids_from_sequences",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizer.create_token_type_ids_from_sequences.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.LayoutLMTokenizer.create_token_type_ids_from_sequences.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm.py#L260",returnDescription:`
<p>List of <a href="../glossary#token-type-ids">token type IDs</a> according to the given sequence(s).</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),Uo=new ft({props:{anchor:"transformers.LayoutLMTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[XM]},$$scope:{ctx:F}}}),os=new ne({props:{name:"get_special_tokens_mask",anchor:"transformers.LayoutLMTokenizer.get_special_tokens_mask",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"},{name:"already_has_special_tokens",val:": bool = False"}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizer.get_special_tokens_mask.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.LayoutLMTokenizer.get_special_tokens_mask.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"},{anchor:"transformers.LayoutLMTokenizer.get_special_tokens_mask.already_has_special_tokens",description:`<strong>already_has_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the token list is already formatted with special tokens for the model.`,name:"already_has_special_tokens"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm.py#L232",returnDescription:`
<p>A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),ss=new ot({}),as=new ne({props:{name:"class transformers.LayoutLMTokenizerFast",anchor:"transformers.LayoutLMTokenizerFast",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:"tokenize_chinese_chars",val:" = True"},{name:"strip_accents",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.clean_text",description:`<strong>clean_text</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to clean the text before tokenization by removing any control characters and replacing all
whitespaces by the classic one.`,name:"clean_text"},{anchor:"transformers.LayoutLMTokenizerFast.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.LayoutLMTokenizerFast.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 LayoutLM).`,name:"strip_accents"},{anchor:"transformers.LayoutLMTokenizerFast.wordpieces_prefix",description:`<strong>wordpieces_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;##&quot;</code>) &#x2014;
The prefix for subwords.`,name:"wordpieces_prefix"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm_fast.py#L62"}}),is=new ne({props:{name:"build_inputs_with_special_tokens",anchor:"transformers.LayoutLMTokenizerFast.build_inputs_with_special_tokens",parameters:[{name:"token_ids_0",val:""},{name:"token_ids_1",val:" = None"}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizerFast.build_inputs_with_special_tokens.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs to which the special tokens will be added.`,name:"token_ids_0"},{anchor:"transformers.LayoutLMTokenizerFast.build_inputs_with_special_tokens.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm_fast.py#L150",returnDescription:`
<p>List of <a href="../glossary#input-ids">input IDs</a> with the appropriate special tokens.</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),cs=new ne({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.LayoutLMTokenizerFast.create_token_type_ids_from_sequences",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"transformers.LayoutLMTokenizerFast.create_token_type_ids_from_sequences.token_ids_0",description:`<strong>token_ids_0</strong> (<code>List[int]</code>) &#x2014;
List of IDs.`,name:"token_ids_0"},{anchor:"transformers.LayoutLMTokenizerFast.create_token_type_ids_from_sequences.token_ids_1",description:`<strong>token_ids_1</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Optional second list of IDs for sequence pairs.`,name:"token_ids_1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/tokenization_layoutlm_fast.py#L174",returnDescription:`
<p>List of <a href="../glossary#token-type-ids">token type IDs</a> according to the given sequence(s).</p>
`,returnType:`
<p><code>List[int]</code></p>
`}}),Eo=new ft({props:{anchor:"transformers.LayoutLMTokenizerFast.create_token_type_ids_from_sequences.example",$$slots:{default:[SM]},$$scope:{ctx:F}}}),ps=new ot({}),us=new ne({props:{name:"class transformers.LayoutLMModel",anchor:"transformers.LayoutLMModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L712"}}),ys=new ne({props:{name:"forward",anchor:"transformers.LayoutLMModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = 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:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",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.LayoutLMModel.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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.LayoutLMModel.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. See <a href="#Overview">Overview</a> for normalization.`,name:"bbox"},{anchor:"transformers.LayoutLMModel.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>: <code>1</code> for
tokens that are NOT MASKED, <code>0</code> for MASKED tokens.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.LayoutLMModel.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>: <code>0</code> corresponds to a <em>sentence A</em> token, <code>1</code> corresponds to a <em>sentence B</em> token</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMModel.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.LayoutLMModel.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>: <code>1</code>
indicates the head is <strong>not masked</strong>, <code>0</code> indicates the head is <strong>masked</strong>.`,name:"head_mask"},{anchor:"transformers.LayoutLMModel.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.LayoutLMModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the attentions tensors of all attention layers are returned. See <code>attentions</code> under
returned tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LayoutLMModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the hidden states of all layers are returned. See <code>hidden_states</code> under returned tensors
for more detail.`,name:"output_hidden_states"},{anchor:"transformers.LayoutLMModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L738",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Fo=new pt({props:{$$slots:{default:[PM]},$$scope:{ctx:F}}}),Io=new ft({props:{anchor:"transformers.LayoutLMModel.forward.example",$$slots:{default:[HM]},$$scope:{ctx:F}}}),_s=new ot({}),Ms=new ne({props:{name:"class transformers.LayoutLMForMaskedLM",anchor:"transformers.LayoutLMForMaskedLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L861"}}),ks=new ne({props:{name:"forward",anchor:"transformers.LayoutLMForMaskedLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = 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:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",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.LayoutLMForMaskedLM.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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.LayoutLMForMaskedLM.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. See <a href="#Overview">Overview</a> for normalization.`,name:"bbox"},{anchor:"transformers.LayoutLMForMaskedLM.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>: <code>1</code> for
tokens that are NOT MASKED, <code>0</code> for MASKED tokens.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.LayoutLMForMaskedLM.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>: <code>0</code> corresponds to a <em>sentence A</em> token, <code>1</code> corresponds to a <em>sentence B</em> token</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMForMaskedLM.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.LayoutLMForMaskedLM.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>: <code>1</code>
indicates the head is <strong>not masked</strong>, <code>0</code> indicates the head is <strong>masked</strong>.`,name:"head_mask"},{anchor:"transformers.LayoutLMForMaskedLM.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.LayoutLMForMaskedLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the attentions tensors of all attention layers are returned. See <code>attentions</code> under
returned tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LayoutLMForMaskedLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the hidden states of all layers are returned. See <code>hidden_states</code> under returned tensors
for more detail.`,name:"output_hidden_states"},{anchor:"transformers.LayoutLMForMaskedLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.LayoutLMForMaskedLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L882",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</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 Masked language modeling (MLM) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>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/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),xo=new pt({props:{$$slots:{default:[OM]},$$scope:{ctx:F}}}),No=new ft({props:{anchor:"transformers.LayoutLMForMaskedLM.forward.example",$$slots:{default:[YM]},$$scope:{ctx:F}}}),vs=new ot({}),Ls=new ne({props:{name:"class transformers.LayoutLMForSequenceClassification",anchor:"transformers.LayoutLMForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L992"}}),Fs=new ne({props:{name:"forward",anchor:"transformers.LayoutLMForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = 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.LayoutLMForSequenceClassification.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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.LayoutLMForSequenceClassification.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. See <a href="#Overview">Overview</a> for normalization.`,name:"bbox"},{anchor:"transformers.LayoutLMForSequenceClassification.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>: <code>1</code> for
tokens that are NOT MASKED, <code>0</code> for MASKED tokens.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.LayoutLMForSequenceClassification.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>: <code>0</code> corresponds to a <em>sentence A</em> token, <code>1</code> corresponds to a <em>sentence B</em> token</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMForSequenceClassification.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.LayoutLMForSequenceClassification.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>: <code>1</code>
indicates the head is <strong>not masked</strong>, <code>0</code> indicates the head is <strong>masked</strong>.`,name:"head_mask"},{anchor:"transformers.LayoutLMForSequenceClassification.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.LayoutLMForSequenceClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the attentions tensors of all attention layers are returned. See <code>attentions</code> under
returned tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LayoutLMForSequenceClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the hidden states of all layers are returned. See <code>hidden_states</code> under returned tensors
for more detail.`,name:"output_hidden_states"},{anchor:"transformers.LayoutLMForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.LayoutLMForSequenceClassification.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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L1006",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</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/main/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ao=new pt({props:{$$slots:{default:[KM]},$$scope:{ctx:F}}}),Ro=new ft({props:{anchor:"transformers.LayoutLMForSequenceClassification.forward.example",$$slots:{default:[eb]},$$scope:{ctx:F}}}),Is=new ot({}),zs=new ne({props:{name:"class transformers.LayoutLMForTokenClassification",anchor:"transformers.LayoutLMForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.LayoutLMForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L1129"}}),Vs=new ne({props:{name:"forward",anchor:"transformers.LayoutLMForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = 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.LayoutLMForTokenClassification.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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__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.LayoutLMForTokenClassification.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. See <a href="#Overview">Overview</a> for normalization.`,name:"bbox"},{anchor:"transformers.LayoutLMForTokenClassification.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>: <code>1</code> for
tokens that are NOT MASKED, <code>0</code> for MASKED tokens.</p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.LayoutLMForTokenClassification.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>: <code>0</code> corresponds to a <em>sentence A</em> token, <code>1</code> corresponds to a <em>sentence B</em> token</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.LayoutLMForTokenClassification.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.LayoutLMForTokenClassification.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>: <code>1</code>
indicates the head is <strong>not masked</strong>, <code>0</code> indicates the head is <strong>masked</strong>.`,name:"head_mask"},{anchor:"transformers.LayoutLMForTokenClassification.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.LayoutLMForTokenClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the attentions tensors of all attention layers are returned. See <code>attentions</code> under
returned tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.LayoutLMForTokenClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the hidden states of all layers are returned. See <code>hidden_states</code> under returned tensors
for more detail.`,name:"output_hidden_states"},{anchor:"transformers.LayoutLMForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.LayoutLMForTokenClassification.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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L1143",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</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/main/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Vo=new pt({props:{$$slots:{default:[tb]},$$scope:{ctx:F}}}),Wo=new ft({props:{anchor:"transformers.LayoutLMForTokenClassification.forward.example",$$slots:{default:[ob]},$$scope:{ctx:F}}}),Ws=new ot({}),Qs=new ne({props:{name:"class transformers.LayoutLMForQuestionAnswering",anchor:"transformers.LayoutLMForQuestionAnswering",parameters:[{name:"config",val:""},{name:"has_visual_segment_embedding",val:" = True"}],parametersDescription:[{anchor:"transformers.LayoutLMForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/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/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L1247"}}),Ps=new ne({props:{name:"forward",anchor:"transformers.LayoutLMForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"bbox",val:": typing.Optional[torch.LongTensor] = 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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_layoutlm.py#L1261",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</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/main/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Bo=new ft({props:{anchor:"transformers.LayoutLMForQuestionAnswering.forward.example",$$slots:{default:[nb]},$$scope:{ctx:F}}}),Hs=new ot({}),Os=new ne({props:{name:"class transformers.TFLayoutLMModel",anchor:"transformers.TFLayoutLMModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFLayoutLMModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L912"}}),Do=new pt({props:{$$slots:{default:[sb]},$$scope:{ctx:F}}}),ta=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"bbox",val:": np.ndarray | tf.Tensor | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_hidden_states",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFLayoutLMModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFLayoutLMModel.call.bbox",description:`<strong>bbox</strong> (<code>Numpy array</code> or <code>tf.Tensor</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>.`,name:"bbox"},{anchor:"transformers.TFLayoutLMModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFLayoutLMModel.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMModel.call.position_ids",description:`<strong>position_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMModel.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the 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.TFLayoutLMModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFLayoutLMModel.call.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.TFLayoutLMModel.call.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.TFLayoutLMModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFLayoutLMModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L918",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions</a> or a tuple of <code>tf.Tensor</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) further processed by a
Linear layer and a Tanh activation function. The Linear layer weights are trained from the next sentence
prediction (classification) objective during pretraining.</p>
<p>This output is usually <em>not</em> a good summary of the semantic content of the input, you\u2019re often better with
averaging or pooling the sequence of hidden-states for the whole input sequence.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings + 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 initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Xo=new pt({props:{$$slots:{default:[ab]},$$scope:{ctx:F}}}),So=new ft({props:{anchor:"transformers.TFLayoutLMModel.call.example",$$slots:{default:[rb]},$$scope:{ctx:F}}}),oa=new ot({}),na=new ne({props:{name:"class transformers.TFLayoutLMForMaskedLM",anchor:"transformers.TFLayoutLMForMaskedLM",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFLayoutLMForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L991"}}),Ho=new pt({props:{$$slots:{default:[lb]},$$scope:{ctx:F}}}),ia=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForMaskedLM.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"bbox",val:": np.ndarray | tf.Tensor | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFLayoutLMForMaskedLM.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFLayoutLMForMaskedLM.call.bbox",description:`<strong>bbox</strong> (<code>Numpy array</code> or <code>tf.Tensor</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>.`,name:"bbox"},{anchor:"transformers.TFLayoutLMForMaskedLM.call.attention_mask",description:`<strong>attention_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFLayoutLMForMaskedLM.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForMaskedLM.call.position_ids",description:`<strong>position_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForMaskedLM.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the 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.TFLayoutLMForMaskedLM.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFLayoutLMForMaskedLM.call.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.TFLayoutLMForMaskedLM.call.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.TFLayoutLMForMaskedLM.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFLayoutLMForMaskedLM.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFLayoutLMForMaskedLM.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> or <code>np.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1019",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFMaskedLMOutput"
>transformers.modeling_tf_outputs.TFMaskedLMOutput</a> or a tuple of <code>tf.Tensor</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(n,)</code>, <em>optional</em>, where n is the number of non-masked labels, returned when <code>labels</code> is provided) \u2014 Masked language modeling (MLM) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings + 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 initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</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/main/en/main_classes/output#transformers.modeling_tf_outputs.TFMaskedLMOutput"
>transformers.modeling_tf_outputs.TFMaskedLMOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Oo=new pt({props:{$$slots:{default:[ib]},$$scope:{ctx:F}}}),Yo=new ft({props:{anchor:"transformers.TFLayoutLMForMaskedLM.call.example",$$slots:{default:[db]},$$scope:{ctx:F}}}),da=new ot({}),ca=new ne({props:{name:"class transformers.TFLayoutLMForSequenceClassification",anchor:"transformers.TFLayoutLMForSequenceClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFLayoutLMForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1118"}}),en=new pt({props:{$$slots:{default:[cb]},$$scope:{ctx:F}}}),ma=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForSequenceClassification.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"bbox",val:": np.ndarray | tf.Tensor | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFLayoutLMForSequenceClassification.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFLayoutLMForSequenceClassification.call.bbox",description:`<strong>bbox</strong> (<code>Numpy array</code> or <code>tf.Tensor</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>.`,name:"bbox"},{anchor:"transformers.TFLayoutLMForSequenceClassification.call.attention_mask",description:`<strong>attention_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFLayoutLMForSequenceClassification.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForSequenceClassification.call.position_ids",description:`<strong>position_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForSequenceClassification.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the 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.TFLayoutLMForSequenceClassification.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFLayoutLMForSequenceClassification.call.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.TFLayoutLMForSequenceClassification.call.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.TFLayoutLMForSequenceClassification.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFLayoutLMForSequenceClassification.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFLayoutLMForSequenceClassification.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> or <code>np.ndarray</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/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1136",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFSequenceClassifierOutput"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutput</a> or a tuple of <code>tf.Tensor</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</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>tf.Tensor</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(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings + 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 initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</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/main/en/main_classes/output#transformers.modeling_tf_outputs.TFSequenceClassifierOutput"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),tn=new pt({props:{$$slots:{default:[pb]},$$scope:{ctx:F}}}),on=new ft({props:{anchor:"transformers.TFLayoutLMForSequenceClassification.call.example",$$slots:{default:[ub]},$$scope:{ctx:F}}}),fa=new ot({}),ga=new ne({props:{name:"class transformers.TFLayoutLMForTokenClassification",anchor:"transformers.TFLayoutLMForTokenClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFLayoutLMForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1236"}}),sn=new pt({props:{$$slots:{default:[hb]},$$scope:{ctx:F}}}),ba=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForTokenClassification.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"bbox",val:": np.ndarray | tf.Tensor | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFLayoutLMForTokenClassification.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFLayoutLMForTokenClassification.call.bbox",description:`<strong>bbox</strong> (<code>Numpy array</code> or <code>tf.Tensor</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>.`,name:"bbox"},{anchor:"transformers.TFLayoutLMForTokenClassification.call.attention_mask",description:`<strong>attention_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFLayoutLMForTokenClassification.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForTokenClassification.call.position_ids",description:`<strong>position_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForTokenClassification.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the 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.TFLayoutLMForTokenClassification.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFLayoutLMForTokenClassification.call.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.TFLayoutLMForTokenClassification.call.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.TFLayoutLMForTokenClassification.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFLayoutLMForTokenClassification.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFLayoutLMForTokenClassification.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> or <code>np.ndarray</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/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1260",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFTokenClassifierOutput"
>transformers.modeling_tf_outputs.TFTokenClassifierOutput</a> or a tuple of <code>tf.Tensor</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(n,)</code>, <em>optional</em>, where n is the number of unmasked labels, returned when <code>labels</code> is provided)  \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</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(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings + 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 initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</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/main/en/main_classes/output#transformers.modeling_tf_outputs.TFTokenClassifierOutput"
>transformers.modeling_tf_outputs.TFTokenClassifierOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),an=new pt({props:{$$slots:{default:[mb]},$$scope:{ctx:F}}}),rn=new ft({props:{anchor:"transformers.TFLayoutLMForTokenClassification.call.example",$$slots:{default:[fb]},$$scope:{ctx:F}}}),Ta=new ot({}),wa=new ne({props:{name:"class transformers.TFLayoutLMForQuestionAnswering",anchor:"transformers.TFLayoutLMForQuestionAnswering",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFLayoutLMForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMConfig">LayoutLMConfig</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/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1359"}}),dn=new pt({props:{$$slots:{default:[gb]},$$scope:{ctx:F}}}),Ua=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForQuestionAnswering.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"bbox",val:": np.ndarray | tf.Tensor | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"start_positions",val:": np.ndarray | tf.Tensor | None = None"},{name:"end_positions",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.bbox",description:`<strong>bbox</strong> (<code>Numpy array</code> or <code>tf.Tensor</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>.`,name:"bbox"},{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.attention_mask",description:`<strong>attention_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForQuestionAnswering.call.position_ids",description:`<strong>position_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</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.TFLayoutLMForQuestionAnswering.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the 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.TFLayoutLMForQuestionAnswering.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.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.TFLayoutLMForQuestionAnswering.call.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.TFLayoutLMForQuestionAnswering.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.start_positions",description:`<strong>start_positions</strong> (<code>tf.Tensor</code> or <code>np.ndarray</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.TFLayoutLMForQuestionAnswering.call.end_positions",description:`<strong>end_positions</strong> (<code>tf.Tensor</code> or <code>np.ndarray</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/main/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1380",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFQuestionAnsweringModelOutput"
>transformers.modeling_tf_outputs.TFQuestionAnsweringModelOutput</a> or a tuple of <code>tf.Tensor</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/main/en/model_doc/layoutlm#transformers.LayoutLMConfig"
>LayoutLMConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>start_positions</code> and <code>end_positions</code> are 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>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>tf.Tensor</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(tf.Tensor)</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>tf.Tensor</code> (one for the output of the embeddings + 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 initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</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>tf.Tensor</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/main/en/main_classes/output#transformers.modeling_tf_outputs.TFQuestionAnsweringModelOutput"
>transformers.modeling_tf_outputs.TFQuestionAnsweringModelOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),cn=new pt({props:{$$slots:{default:[yb]},$$scope:{ctx:F}}}),pn=new ft({props:{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.example",$$slots:{default:[_b]},$$scope:{ctx:F}}}),{c(){d=a("meta"),b=c(),f=a("h1"),g=a("a"),M=a("span"),w(i.$$.fragment),h=c(),E=a("span"),Le=n("LayoutLM"),ye=c(),W=a("a"),_e=c(),G=a("h2"),T=a("a"),he=a("span"),w(R.$$.fragment),je=c(),me=a("span"),D=n("Overview"),Me=c(),se=a("p"),X=n("The LayoutLM model was proposed in the paper "),le=a("a"),Ue=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),S=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei, and
Ming Zhou. It\u2019s a simple but effective pretraining method of text and layout for document image understanding and
information extraction tasks, such as form understanding and receipt understanding. It obtains state-of-the-art results
on several downstream tasks:`),be=c(),oe=a("ul"),Z=a("li"),Je=n("form understanding: the "),ie=a("a"),ae=n("FUNSD"),$=n(` dataset (a collection of 199 annotated
forms comprising more than 30,000 words).`),I=c(),de=a("li"),P=n("receipt understanding: the "),ce=a("a"),Ce=n("SROIE"),H=n(` dataset (a collection of 626 receipts for
training and 347 receipts for testing).`),Ee=c(),pe=a("li"),z=n("document image classification: the "),ue=a("a"),O=n("RVL-CDIP"),$e=n(` dataset (a collection of
400,000 images belonging to one of 16 classes).`),Te=c(),Q=a("p"),Fe=n("The abstract from the paper is the following:"),we=c(),A=a("p"),fe=a("em"),Y=n(`Pre-training techniques have been verified successfully in a variety of NLP tasks in recent years. Despite the
widespread use of pretraining models for NLP applications, they almost exclusively focus on text-level manipulation,
while neglecting layout and style information that is vital for document image understanding. In this paper, we propose
the LayoutLM to jointly model interactions between text and layout information across scanned document images, which is
beneficial for a great number of real-world document image understanding tasks such as information extraction from
scanned documents. Furthermore, we also leverage image features to incorporate words\u2019 visual information into LayoutLM.
To the best of our knowledge, this is the first time that text and layout are jointly learned in a single framework for
document-level pretraining. It achieves new state-of-the-art results in several downstream tasks, including form
understanding (from 70.72 to 79.27), receipt understanding (from 94.02 to 95.24) and document image classification
(from 93.07 to 94.42).`),ke=c(),ee=a("p"),x=n("Tips:"),ve=c(),N=a("ul"),B=a("li"),Ie=n("In addition to "),_=a("em"),J=n("input_ids"),Ve=n(", "),te=a("a"),We=n("forward()"),Qe=n(" also expects the input "),C=a("code"),Be=n("bbox"),Ge=n(`, which are
the bounding boxes (i.e. 2D-positions) of the input tokens. These can be obtained using an external OCR engine such
as Google\u2019s `),xe=a("a"),De=n("Tesseract"),Xe=n(" (there\u2019s a "),q=a("a"),K=n("Python wrapper"),Se=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:`),Ae=c(),w(V.$$.fragment),Re=c(),ge=a("p"),ze=n("Here, "),qe=a("code"),re=n("width"),Pe=n(" and "),$r=a("code"),rc=n("height"),lc=n(` correspond to the width and height of the original document in which the token
occurs. Those can be obtained using the Python Image Library (PIL) library for example, as follows:`),ki=c(),w(Cn.$$.fragment),vi=c(),Qt=a("h2"),bo=a("a"),Fr=a("span"),w(En.$$.fragment),ic=c(),Ir=a("span"),dc=n("Resources"),Li=c(),za=a("p"),cc=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with LayoutLM. 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."),ji=c(),w($n.$$.fragment),Ui=c(),yt=a("ul"),zr=a("li"),Fn=a("p"),pc=n("A blog post on "),In=a("a"),uc=n(`fine-tuning
LayoutLM for document-understanding using Keras & Hugging Face
Transformers`),hc=n("."),mc=c(),xr=a("li"),zn=a("p"),fc=n("A blog post on how to "),xn=a("a"),gc=n("fine-tune LayoutLM for document-understanding using only Hugging Face Transformers"),yc=n("."),_c=c(),Nr=a("li"),Nn=a("p"),Mc=n("A notebook on how to "),qn=a("a"),bc=n("fine-tune LayoutLM on the FUNSD dataset with image embeddings"),Tc=n("."),wc=c(),qr=a("li"),xa=a("p"),kc=n("See also: "),Na=a("a"),vc=n("Document question answering task guide"),Ji=c(),w(An.$$.fragment),Ci=c(),To=a("ul"),Rn=a("li"),Lc=n("A notebook on how to "),Zn=a("a"),jc=n("fine-tune LayoutLM for sequence classification on the RVL-CDIP dataset"),Uc=n("."),Jc=c(),Ar=a("li"),qa=a("a"),Cc=n("Text classification task guide"),Ei=c(),w(Vn.$$.fragment),$i=c(),wo=a("ul"),Wn=a("li"),Ec=n("A notebook on how to "),Qn=a("a"),$c=n("fine-tune LayoutLM for token classification on the FUNSD dataset"),Fc=n("."),Ic=c(),Rr=a("li"),Aa=a("a"),zc=n("Token classification task guide"),Fi=c(),Ra=a("p"),Zr=a("strong"),xc=n("Other resources"),Ii=c(),Za=a("ul"),Vr=a("li"),Va=a("a"),Nc=n("Masked language modeling task guide"),zi=c(),Wa=a("p"),qc=n("\u{1F680} Deploy"),xi=c(),Qa=a("ul"),Bn=a("li"),Ac=n("A blog post on how to "),Gn=a("a"),Rc=n("Deploy LayoutLM with Hugging Face Inference Endpoints"),Zc=n("."),Ni=c(),Bt=a("h2"),ko=a("a"),Wr=a("span"),w(Dn.$$.fragment),Vc=c(),Qr=a("span"),Wc=n("LayoutLMConfig"),qi=c(),ut=a("div"),w(Xn.$$.fragment),Qc=c(),Gt=a("p"),Bc=n("This is the configuration class to store the configuration of a "),Ba=a("a"),Gc=n("LayoutLMModel"),Dc=n(`. It is used to instantiate a
LayoutLM 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 LayoutLM
`),Sn=a("a"),Xc=n("microsoft/layoutlm-base-uncased"),Sc=n(" architecture."),Pc=c(),Dt=a("p"),Hc=n("Configuration objects inherit from "),Ga=a("a"),Oc=n("BertConfig"),Yc=n(` and can be used to control the model outputs. Read the
documentation from `),Da=a("a"),Kc=n("BertConfig"),ep=n(" for more information."),tp=c(),w(vo.$$.fragment),Ai=c(),Xt=a("h2"),Lo=a("a"),Br=a("span"),w(Pn.$$.fragment),op=c(),Gr=a("span"),np=n("LayoutLMTokenizer"),Ri=c(),Ze=a("div"),w(Hn.$$.fragment),sp=c(),Dr=a("p"),ap=n("Construct a LayoutLM tokenizer. Based on WordPiece."),rp=c(),On=a("p"),lp=n("This tokenizer inherits from "),Xa=a("a"),ip=n("PreTrainedTokenizer"),dp=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),cp=c(),Nt=a("div"),w(Yn.$$.fragment),pp=c(),Xr=a("p"),up=n(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A LayoutLM sequence has the following format:`),hp=c(),Kn=a("ul"),Sa=a("li"),mp=n("single sequence: "),Sr=a("code"),fp=n("[CLS] X [SEP]"),gp=c(),Pa=a("li"),yp=n("pair of sequences: "),Pr=a("code"),_p=n("[CLS] A [SEP] B [SEP]"),Mp=c(),jo=a("div"),w(es.$$.fragment),bp=c(),Hr=a("p"),Tp=n("Converts a sequence of tokens (string) in a single string."),wp=c(),_t=a("div"),w(ts.$$.fragment),kp=c(),Or=a("p"),vp=n("Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),Lp=c(),w(Uo.$$.fragment),jp=c(),St=a("p"),Up=n("If "),Yr=a("code"),Jp=n("token_ids_1"),Cp=n(" is "),Kr=a("code"),Ep=n("None"),$p=n(", this method only returns the first portion of the mask (0s)."),Fp=c(),Jo=a("div"),w(os.$$.fragment),Ip=c(),ns=a("p"),zp=n(`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),el=a("code"),xp=n("prepare_for_model"),Np=n(" method."),Zi=c(),Pt=a("h2"),Co=a("a"),tl=a("span"),w(ss.$$.fragment),qp=c(),ol=a("span"),Ap=n("LayoutLMTokenizerFast"),Vi=c(),nt=a("div"),w(as.$$.fragment),Rp=c(),rs=a("p"),Zp=n("Construct a \u201Cfast\u201D LayoutLM tokenizer (backed by HuggingFace\u2019s "),nl=a("em"),Vp=n("tokenizers"),Wp=n(" library). Based on WordPiece."),Qp=c(),ls=a("p"),Bp=n("This tokenizer inherits from "),Ha=a("a"),Gp=n("PreTrainedTokenizerFast"),Dp=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Xp=c(),qt=a("div"),w(is.$$.fragment),Sp=c(),sl=a("p"),Pp=n(`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A LayoutLM sequence has the following format:`),Hp=c(),ds=a("ul"),Oa=a("li"),Op=n("single sequence: "),al=a("code"),Yp=n("[CLS] X [SEP]"),Kp=c(),Ya=a("li"),eu=n("pair of sequences: "),rl=a("code"),tu=n("[CLS] A [SEP] B [SEP]"),ou=c(),Mt=a("div"),w(cs.$$.fragment),nu=c(),ll=a("p"),su=n("Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),au=c(),w(Eo.$$.fragment),ru=c(),Ht=a("p"),lu=n("If "),il=a("code"),iu=n("token_ids_1"),du=n(" is "),dl=a("code"),cu=n("None"),pu=n(", this method only returns the first portion of the mask (0s)."),Wi=c(),Ot=a("h2"),$o=a("a"),cl=a("span"),w(ps.$$.fragment),uu=c(),pl=a("span"),hu=n("LayoutLMModel"),Qi=c(),ht=a("div"),w(us.$$.fragment),mu=c(),hs=a("p"),fu=n(`The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top.
The LayoutLM model was proposed in `),ms=a("a"),gu=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),yu=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),_u=c(),fs=a("p"),Mu=n("This model is a PyTorch "),gs=a("a"),bu=n("torch.nn.Module"),Tu=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.`),wu=c(),bt=a("div"),w(ys.$$.fragment),ku=c(),Yt=a("p"),vu=n("The "),Ka=a("a"),Lu=n("LayoutLMModel"),ju=n(" forward method, overrides the "),ul=a("code"),Uu=n("__call__"),Ju=n(" special method."),Cu=c(),w(Fo.$$.fragment),Eu=c(),w(Io.$$.fragment),Bi=c(),Kt=a("h2"),zo=a("a"),hl=a("span"),w(_s.$$.fragment),$u=c(),ml=a("span"),Fu=n("LayoutLMForMaskedLM"),Gi=c(),mt=a("div"),w(Ms.$$.fragment),Iu=c(),eo=a("p"),zu=n("LayoutLM Model with a "),fl=a("code"),xu=n("language modeling"),Nu=n(` head on top.
The LayoutLM model was proposed in `),bs=a("a"),qu=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),Au=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Ru=c(),Ts=a("p"),Zu=n("This model is a PyTorch "),ws=a("a"),Vu=n("torch.nn.Module"),Wu=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.`),Qu=c(),Tt=a("div"),w(ks.$$.fragment),Bu=c(),to=a("p"),Gu=n("The "),er=a("a"),Du=n("LayoutLMForMaskedLM"),Xu=n(" forward method, overrides the "),gl=a("code"),Su=n("__call__"),Pu=n(" special method."),Hu=c(),w(xo.$$.fragment),Ou=c(),w(No.$$.fragment),Di=c(),oo=a("h2"),qo=a("a"),yl=a("span"),w(vs.$$.fragment),Yu=c(),_l=a("span"),Ku=n("LayoutLMForSequenceClassification"),Xi=c(),st=a("div"),w(Ls.$$.fragment),eh=c(),js=a("p"),th=n(`LayoutLM Model with a sequence classification head on top (a linear layer on top of the pooled output) e.g. for
document image classification tasks such as the `),Us=a("a"),oh=n("RVL-CDIP"),nh=n(" dataset."),sh=c(),Js=a("p"),ah=n("The LayoutLM model was proposed in "),Cs=a("a"),rh=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),lh=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),ih=c(),Es=a("p"),dh=n("This model is a PyTorch "),$s=a("a"),ch=n("torch.nn.Module"),ph=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.`),uh=c(),wt=a("div"),w(Fs.$$.fragment),hh=c(),no=a("p"),mh=n("The "),tr=a("a"),fh=n("LayoutLMForSequenceClassification"),gh=n(" forward method, overrides the "),Ml=a("code"),yh=n("__call__"),_h=n(" special method."),Mh=c(),w(Ao.$$.fragment),bh=c(),w(Ro.$$.fragment),Si=c(),so=a("h2"),Zo=a("a"),bl=a("span"),w(Is.$$.fragment),Th=c(),Tl=a("span"),wh=n("LayoutLMForTokenClassification"),Pi=c(),at=a("div"),w(zs.$$.fragment),kh=c(),ao=a("p"),vh=n(`LayoutLM Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
sequence labeling (information extraction) tasks such as the `),xs=a("a"),Lh=n("FUNSD"),jh=n(`
dataset and the `),Ns=a("a"),Uh=n("SROIE"),Jh=n(" dataset."),Ch=c(),qs=a("p"),Eh=n("The LayoutLM model was proposed in "),As=a("a"),$h=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),Fh=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Ih=c(),Rs=a("p"),zh=n("This model is a PyTorch "),Zs=a("a"),xh=n("torch.nn.Module"),Nh=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.`),qh=c(),kt=a("div"),w(Vs.$$.fragment),Ah=c(),ro=a("p"),Rh=n("The "),or=a("a"),Zh=n("LayoutLMForTokenClassification"),Vh=n(" forward method, overrides the "),wl=a("code"),Wh=n("__call__"),Qh=n(" special method."),Bh=c(),w(Vo.$$.fragment),Gh=c(),w(Wo.$$.fragment),Hi=c(),lo=a("h2"),Qo=a("a"),kl=a("span"),w(Ws.$$.fragment),Dh=c(),vl=a("span"),Xh=n("LayoutLMForQuestionAnswering"),Oi=c(),rt=a("div"),w(Qs.$$.fragment),Sh=c(),zt=a("p"),Ph=n(`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),Bs=a("a"),Hh=n("DocVQA"),Oh=n(" (a linear layer on top of the final hidden-states output to compute "),Ll=a("code"),Yh=n("span start logits"),Kh=n(" and "),jl=a("code"),em=n("span end logits"),tm=n(")."),om=c(),Gs=a("p"),nm=n("The LayoutLM model was proposed in "),Ds=a("a"),sm=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),am=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),rm=c(),Xs=a("p"),lm=n("This model is a PyTorch "),Ss=a("a"),im=n("torch.nn.Module"),dm=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.`),cm=c(),dt=a("div"),w(Ps.$$.fragment),pm=c(),Ne=a("p"),um=n("start_positions ("),Ul=a("code"),hm=n("torch.LongTensor"),mm=n(" of shape "),Jl=a("code"),fm=n("(batch_size,)"),gm=n(", "),Cl=a("em"),ym=n("optional"),_m=n(`):
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 (`),El=a("code"),Mm=n("sequence_length"),bm=n(`). Position outside of the sequence
are not taken into account for computing the loss.
end_positions (`),$l=a("code"),Tm=n("torch.LongTensor"),wm=n(" of shape "),Fl=a("code"),km=n("(batch_size,)"),vm=n(", "),Il=a("em"),Lm=n("optional"),jm=n(`):
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 (`),zl=a("code"),Um=n("sequence_length"),Jm=n(`). Position outside of the sequence
are not taken into account for computing the loss.`),Cm=c(),xl=a("p"),Em=n("Example:"),$m=c(),Nl=a("p"),Fm=n(`In the example below, we prepare a question + context pair for the LayoutLM model. 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).`),Im=c(),w(Bo.$$.fragment),Yi=c(),io=a("h2"),Go=a("a"),ql=a("span"),w(Hs.$$.fragment),zm=c(),Al=a("span"),xm=n("TFLayoutLMModel"),Ki=c(),Oe=a("div"),w(Os.$$.fragment),Nm=c(),Rl=a("p"),qm=n("The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top."),Am=c(),Ys=a("p"),Rm=n("This model inherits from "),nr=a("a"),Zm=n("TFPreTrainedModel"),Vm=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Wm=c(),Ks=a("p"),Qm=n("This model is also a "),ea=a("a"),Bm=n("tf.keras.Model"),Gm=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Dm=c(),w(Do.$$.fragment),Xm=c(),vt=a("div"),w(ta.$$.fragment),Sm=c(),co=a("p"),Pm=n("The "),sr=a("a"),Hm=n("TFLayoutLMModel"),Om=n(" forward method, overrides the "),Zl=a("code"),Ym=n("__call__"),Km=n(" special method."),ef=c(),w(Xo.$$.fragment),tf=c(),w(So.$$.fragment),ed=c(),po=a("h2"),Po=a("a"),Vl=a("span"),w(oa.$$.fragment),of=c(),Wl=a("span"),nf=n("TFLayoutLMForMaskedLM"),td=c(),Ye=a("div"),w(na.$$.fragment),sf=c(),sa=a("p"),af=n("LayoutLM Model with a "),Ql=a("code"),rf=n("language modeling"),lf=n(" head on top."),df=c(),aa=a("p"),cf=n("This model inherits from "),ar=a("a"),pf=n("TFPreTrainedModel"),uf=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),hf=c(),ra=a("p"),mf=n("This model is also a "),la=a("a"),ff=n("tf.keras.Model"),gf=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),yf=c(),w(Ho.$$.fragment),_f=c(),Lt=a("div"),w(ia.$$.fragment),Mf=c(),uo=a("p"),bf=n("The "),rr=a("a"),Tf=n("TFLayoutLMForMaskedLM"),wf=n(" forward method, overrides the "),Bl=a("code"),kf=n("__call__"),vf=n(" special method."),Lf=c(),w(Oo.$$.fragment),jf=c(),w(Yo.$$.fragment),od=c(),ho=a("h2"),Ko=a("a"),Gl=a("span"),w(da.$$.fragment),Uf=c(),Dl=a("span"),Jf=n("TFLayoutLMForSequenceClassification"),nd=c(),Ke=a("div"),w(ca.$$.fragment),Cf=c(),Xl=a("p"),Ef=n(`LayoutLM Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),$f=c(),pa=a("p"),Ff=n("This model inherits from "),lr=a("a"),If=n("TFPreTrainedModel"),zf=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),xf=c(),ua=a("p"),Nf=n("This model is also a "),ha=a("a"),qf=n("tf.keras.Model"),Af=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Rf=c(),w(en.$$.fragment),Zf=c(),jt=a("div"),w(ma.$$.fragment),Vf=c(),mo=a("p"),Wf=n("The "),ir=a("a"),Qf=n("TFLayoutLMForSequenceClassification"),Bf=n(" forward method, overrides the "),Sl=a("code"),Gf=n("__call__"),Df=n(" special method."),Xf=c(),w(tn.$$.fragment),Sf=c(),w(on.$$.fragment),sd=c(),fo=a("h2"),nn=a("a"),Pl=a("span"),w(fa.$$.fragment),Pf=c(),Hl=a("span"),Hf=n("TFLayoutLMForTokenClassification"),ad=c(),et=a("div"),w(ga.$$.fragment),Of=c(),Ol=a("p"),Yf=n(`LayoutLM Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),Kf=c(),ya=a("p"),eg=n("This model inherits from "),dr=a("a"),tg=n("TFPreTrainedModel"),og=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ng=c(),_a=a("p"),sg=n("This model is also a "),Ma=a("a"),ag=n("tf.keras.Model"),rg=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),lg=c(),w(sn.$$.fragment),ig=c(),Ut=a("div"),w(ba.$$.fragment),dg=c(),go=a("p"),cg=n("The "),cr=a("a"),pg=n("TFLayoutLMForTokenClassification"),ug=n(" forward method, overrides the "),Yl=a("code"),hg=n("__call__"),mg=n(" special method."),fg=c(),w(an.$$.fragment),gg=c(),w(rn.$$.fragment),rd=c(),yo=a("h2"),ln=a("a"),Kl=a("span"),w(Ta.$$.fragment),yg=c(),ei=a("span"),_g=n("TFLayoutLMForQuestionAnswering"),ld=c(),tt=a("div"),w(wa.$$.fragment),Mg=c(),xt=a("p"),bg=n(`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),ka=a("a"),Tg=n("DocVQA"),wg=n(" (a linear layer on top of the final hidden-states output to compute "),ti=a("code"),kg=n("span start logits"),vg=n(" and "),oi=a("code"),Lg=n("span end logits"),jg=n(")."),Ug=c(),va=a("p"),Jg=n("This model inherits from "),pr=a("a"),Cg=n("TFPreTrainedModel"),Eg=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),$g=c(),La=a("p"),Fg=n("This model is also a "),ja=a("a"),Ig=n("tf.keras.Model"),zg=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),xg=c(),w(dn.$$.fragment),Ng=c(),Jt=a("div"),w(Ua.$$.fragment),qg=c(),_o=a("p"),Ag=n("The "),ur=a("a"),Rg=n("TFLayoutLMForQuestionAnswering"),Zg=n(" forward method, overrides the "),ni=a("code"),Vg=n("__call__"),Wg=n(" special method."),Qg=c(),w(cn.$$.fragment),Bg=c(),w(pn.$$.fragment),this.h()},l(o){const y=BM('[data-svelte="svelte-1phssyn"]',document.head);d=r(y,"META",{name:!0,content:!0}),y.forEach(t),b=p(o),f=r(o,"H1",{class:!0});var Ja=l(f);g=r(Ja,"A",{id:!0,class:!0,href:!0});var si=l(g);M=r(si,"SPAN",{});var ai=l(M);k(i.$$.fragment,ai),ai.forEach(t),si.forEach(t),h=p(Ja),E=r(Ja,"SPAN",{});var ri=l(E);Le=s(ri,"LayoutLM"),ri.forEach(t),Ja.forEach(t),ye=p(o),W=r(o,"A",{id:!0}),l(W).forEach(t),_e=p(o),G=r(o,"H2",{class:!0});var Ca=l(G);T=r(Ca,"A",{id:!0,class:!0,href:!0});var li=l(T);he=r(li,"SPAN",{});var ii=l(he);k(R.$$.fragment,ii),ii.forEach(t),li.forEach(t),je=p(Ca),me=r(Ca,"SPAN",{});var di=l(me);D=s(di,"Overview"),di.forEach(t),Ca.forEach(t),Me=p(o),se=r(o,"P",{});var Ea=l(se);X=s(Ea,"The LayoutLM model was proposed in the paper "),le=r(Ea,"A",{href:!0,rel:!0});var ci=l(le);Ue=s(ci,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),ci.forEach(t),S=s(Ea,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei, and
Ming Zhou. It\u2019s a simple but effective pretraining method of text and layout for document image understanding and
information extraction tasks, such as form understanding and receipt understanding. It obtains state-of-the-art results
on several downstream tasks:`),Ea.forEach(t),be=p(o),oe=r(o,"UL",{});var Mo=l(oe);Z=r(Mo,"LI",{});var $a=l(Z);Je=s($a,"form understanding: the "),ie=r($a,"A",{href:!0,rel:!0});var pi=l(ie);ae=s(pi,"FUNSD"),pi.forEach(t),$=s($a,` dataset (a collection of 199 annotated
forms comprising more than 30,000 words).`),$a.forEach(t),I=p(Mo),de=r(Mo,"LI",{});var Fa=l(de);P=s(Fa,"receipt understanding: the "),ce=r(Fa,"A",{href:!0,rel:!0});var ui=l(ce);Ce=s(ui,"SROIE"),ui.forEach(t),H=s(Fa,` dataset (a collection of 626 receipts for
training and 347 receipts for testing).`),Fa.forEach(t),Ee=p(Mo),pe=r(Mo,"LI",{});var Ia=l(pe);z=s(Ia,"document image classification: the "),ue=r(Ia,"A",{href:!0,rel:!0});var hi=l(ue);O=s(hi,"RVL-CDIP"),hi.forEach(t),$e=s(Ia,` dataset (a collection of
400,000 images belonging to one of 16 classes).`),Ia.forEach(t),Mo.forEach(t),Te=p(o),Q=r(o,"P",{});var mi=l(Q);Fe=s(mi,"The abstract from the paper is the following:"),mi.forEach(t),we=p(o),A=r(o,"P",{});var fi=l(A);fe=r(fi,"EM",{});var gi=l(fe);Y=s(gi,`Pre-training techniques have been verified successfully in a variety of NLP tasks in recent years. Despite the
widespread use of pretraining models for NLP applications, they almost exclusively focus on text-level manipulation,
while neglecting layout and style information that is vital for document image understanding. In this paper, we propose
the LayoutLM to jointly model interactions between text and layout information across scanned document images, which is
beneficial for a great number of real-world document image understanding tasks such as information extraction from
scanned documents. Furthermore, we also leverage image features to incorporate words\u2019 visual information into LayoutLM.
To the best of our knowledge, this is the first time that text and layout are jointly learned in a single framework for
document-level pretraining. It achieves new state-of-the-art results in several downstream tasks, including form
understanding (from 70.72 to 79.27), receipt understanding (from 94.02 to 95.24) and document image classification
(from 93.07 to 94.42).`),gi.forEach(t),fi.forEach(t),ke=p(o),ee=r(o,"P",{});var yi=l(ee);x=s(yi,"Tips:"),yi.forEach(t),ve=p(o),N=r(o,"UL",{});var _i=l(N);B=r(_i,"LI",{});var lt=l(B);Ie=s(lt,"In addition to "),_=r(lt,"EM",{});var Mi=l(_);J=s(Mi,"input_ids"),Mi.forEach(t),Ve=s(lt,", "),te=r(lt,"A",{href:!0});var bi=l(te);We=s(bi,"forward()"),bi.forEach(t),Qe=s(lt," also expects the input "),C=r(lt,"CODE",{});var Ti=l(C);Be=s(Ti,"bbox"),Ti.forEach(t),Ge=s(lt,`, which are
the bounding boxes (i.e. 2D-positions) of the input tokens. These can be obtained using an external OCR engine such
as Google\u2019s `),xe=r(lt,"A",{href:!0,rel:!0});var wi=l(xe);De=s(wi,"Tesseract"),wi.forEach(t),Xe=s(lt," (there\u2019s a "),q=r(lt,"A",{href:!0,rel:!0});var Og=l(q);K=s(Og,"Python wrapper"),Og.forEach(t),Se=s(lt,` 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:`),lt.forEach(t),_i.forEach(t),Ae=p(o),k(V.$$.fragment,o),Re=p(o),ge=r(o,"P",{});var hr=l(ge);ze=s(hr,"Here, "),qe=r(hr,"CODE",{});var Yg=l(qe);re=s(Yg,"width"),Yg.forEach(t),Pe=s(hr," and "),$r=r(hr,"CODE",{});var Kg=l($r);rc=s(Kg,"height"),Kg.forEach(t),lc=s(hr,` correspond to the width and height of the original document in which the token
occurs. Those can be obtained using the Python Image Library (PIL) library for example, as follows:`),hr.forEach(t),ki=p(o),k(Cn.$$.fragment,o),vi=p(o),Qt=r(o,"H2",{class:!0});var dd=l(Qt);bo=r(dd,"A",{id:!0,class:!0,href:!0});var ey=l(bo);Fr=r(ey,"SPAN",{});var ty=l(Fr);k(En.$$.fragment,ty),ty.forEach(t),ey.forEach(t),ic=p(dd),Ir=r(dd,"SPAN",{});var oy=l(Ir);dc=s(oy,"Resources"),oy.forEach(t),dd.forEach(t),Li=p(o),za=r(o,"P",{});var ny=l(za);cc=s(ny,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with LayoutLM. 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."),ny.forEach(t),ji=p(o),k($n.$$.fragment,o),Ui=p(o),yt=r(o,"UL",{});var un=l(yt);zr=r(un,"LI",{});var sy=l(zr);Fn=r(sy,"P",{});var cd=l(Fn);pc=s(cd,"A blog post on "),In=r(cd,"A",{href:!0,rel:!0});var ay=l(In);uc=s(ay,`fine-tuning
LayoutLM for document-understanding using Keras & Hugging Face
Transformers`),ay.forEach(t),hc=s(cd,"."),cd.forEach(t),sy.forEach(t),mc=p(un),xr=r(un,"LI",{});var ry=l(xr);zn=r(ry,"P",{});var pd=l(zn);fc=s(pd,"A blog post on how to "),xn=r(pd,"A",{href:!0,rel:!0});var ly=l(xn);gc=s(ly,"fine-tune LayoutLM for document-understanding using only Hugging Face Transformers"),ly.forEach(t),yc=s(pd,"."),pd.forEach(t),ry.forEach(t),_c=p(un),Nr=r(un,"LI",{});var iy=l(Nr);Nn=r(iy,"P",{});var ud=l(Nn);Mc=s(ud,"A notebook on how to "),qn=r(ud,"A",{href:!0,rel:!0});var dy=l(qn);bc=s(dy,"fine-tune LayoutLM on the FUNSD dataset with image embeddings"),dy.forEach(t),Tc=s(ud,"."),ud.forEach(t),iy.forEach(t),wc=p(un),qr=r(un,"LI",{});var cy=l(qr);xa=r(cy,"P",{});var Gg=l(xa);kc=s(Gg,"See also: "),Na=r(Gg,"A",{href:!0});var py=l(Na);vc=s(py,"Document question answering task guide"),py.forEach(t),Gg.forEach(t),cy.forEach(t),un.forEach(t),Ji=p(o),k(An.$$.fragment,o),Ci=p(o),To=r(o,"UL",{});var hd=l(To);Rn=r(hd,"LI",{});var md=l(Rn);Lc=s(md,"A notebook on how to "),Zn=r(md,"A",{href:!0,rel:!0});var uy=l(Zn);jc=s(uy,"fine-tune LayoutLM for sequence classification on the RVL-CDIP dataset"),uy.forEach(t),Uc=s(md,"."),md.forEach(t),Jc=p(hd),Ar=r(hd,"LI",{});var hy=l(Ar);qa=r(hy,"A",{href:!0});var my=l(qa);Cc=s(my,"Text classification task guide"),my.forEach(t),hy.forEach(t),hd.forEach(t),Ei=p(o),k(Vn.$$.fragment,o),$i=p(o),wo=r(o,"UL",{});var fd=l(wo);Wn=r(fd,"LI",{});var gd=l(Wn);Ec=s(gd,"A notebook on how to "),Qn=r(gd,"A",{href:!0,rel:!0});var fy=l(Qn);$c=s(fy,"fine-tune LayoutLM for token classification on the FUNSD dataset"),fy.forEach(t),Fc=s(gd,"."),gd.forEach(t),Ic=p(fd),Rr=r(fd,"LI",{});var gy=l(Rr);Aa=r(gy,"A",{href:!0});var yy=l(Aa);zc=s(yy,"Token classification task guide"),yy.forEach(t),gy.forEach(t),fd.forEach(t),Fi=p(o),Ra=r(o,"P",{});var _y=l(Ra);Zr=r(_y,"STRONG",{});var My=l(Zr);xc=s(My,"Other resources"),My.forEach(t),_y.forEach(t),Ii=p(o),Za=r(o,"UL",{});var by=l(Za);Vr=r(by,"LI",{});var Ty=l(Vr);Va=r(Ty,"A",{href:!0});var wy=l(Va);Nc=s(wy,"Masked language modeling task guide"),wy.forEach(t),Ty.forEach(t),by.forEach(t),zi=p(o),Wa=r(o,"P",{});var ky=l(Wa);qc=s(ky,"\u{1F680} Deploy"),ky.forEach(t),xi=p(o),Qa=r(o,"UL",{});var vy=l(Qa);Bn=r(vy,"LI",{});var yd=l(Bn);Ac=s(yd,"A blog post on how to "),Gn=r(yd,"A",{href:!0,rel:!0});var Ly=l(Gn);Rc=s(Ly,"Deploy LayoutLM with Hugging Face Inference Endpoints"),Ly.forEach(t),Zc=s(yd,"."),yd.forEach(t),vy.forEach(t),Ni=p(o),Bt=r(o,"H2",{class:!0});var _d=l(Bt);ko=r(_d,"A",{id:!0,class:!0,href:!0});var jy=l(ko);Wr=r(jy,"SPAN",{});var Uy=l(Wr);k(Dn.$$.fragment,Uy),Uy.forEach(t),jy.forEach(t),Vc=p(_d),Qr=r(_d,"SPAN",{});var Jy=l(Qr);Wc=s(Jy,"LayoutLMConfig"),Jy.forEach(t),_d.forEach(t),qi=p(o),ut=r(o,"DIV",{class:!0});var hn=l(ut);k(Xn.$$.fragment,hn),Qc=p(hn),Gt=r(hn,"P",{});var mr=l(Gt);Bc=s(mr,"This is the configuration class to store the configuration of a "),Ba=r(mr,"A",{href:!0});var Cy=l(Ba);Gc=s(Cy,"LayoutLMModel"),Cy.forEach(t),Dc=s(mr,`. It is used to instantiate a
LayoutLM 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 LayoutLM
`),Sn=r(mr,"A",{href:!0,rel:!0});var Ey=l(Sn);Xc=s(Ey,"microsoft/layoutlm-base-uncased"),Ey.forEach(t),Sc=s(mr," architecture."),mr.forEach(t),Pc=p(hn),Dt=r(hn,"P",{});var fr=l(Dt);Hc=s(fr,"Configuration objects inherit from "),Ga=r(fr,"A",{href:!0});var $y=l(Ga);Oc=s($y,"BertConfig"),$y.forEach(t),Yc=s(fr,` and can be used to control the model outputs. Read the
documentation from `),Da=r(fr,"A",{href:!0});var Fy=l(Da);Kc=s(Fy,"BertConfig"),Fy.forEach(t),ep=s(fr," for more information."),fr.forEach(t),tp=p(hn),k(vo.$$.fragment,hn),hn.forEach(t),Ai=p(o),Xt=r(o,"H2",{class:!0});var Md=l(Xt);Lo=r(Md,"A",{id:!0,class:!0,href:!0});var Iy=l(Lo);Br=r(Iy,"SPAN",{});var zy=l(Br);k(Pn.$$.fragment,zy),zy.forEach(t),Iy.forEach(t),op=p(Md),Gr=r(Md,"SPAN",{});var xy=l(Gr);np=s(xy,"LayoutLMTokenizer"),xy.forEach(t),Md.forEach(t),Ri=p(o),Ze=r(o,"DIV",{class:!0});var ct=l(Ze);k(Hn.$$.fragment,ct),sp=p(ct),Dr=r(ct,"P",{});var Ny=l(Dr);ap=s(Ny,"Construct a LayoutLM tokenizer. Based on WordPiece."),Ny.forEach(t),rp=p(ct),On=r(ct,"P",{});var bd=l(On);lp=s(bd,"This tokenizer inherits from "),Xa=r(bd,"A",{href:!0});var qy=l(Xa);ip=s(qy,"PreTrainedTokenizer"),qy.forEach(t),dp=s(bd,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),bd.forEach(t),cp=p(ct),Nt=r(ct,"DIV",{class:!0});var gr=l(Nt);k(Yn.$$.fragment,gr),pp=p(gr),Xr=r(gr,"P",{});var Ay=l(Xr);up=s(Ay,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A LayoutLM sequence has the following format:`),Ay.forEach(t),hp=p(gr),Kn=r(gr,"UL",{});var Td=l(Kn);Sa=r(Td,"LI",{});var Dg=l(Sa);mp=s(Dg,"single sequence: "),Sr=r(Dg,"CODE",{});var Ry=l(Sr);fp=s(Ry,"[CLS] X [SEP]"),Ry.forEach(t),Dg.forEach(t),gp=p(Td),Pa=r(Td,"LI",{});var Xg=l(Pa);yp=s(Xg,"pair of sequences: "),Pr=r(Xg,"CODE",{});var Zy=l(Pr);_p=s(Zy,"[CLS] A [SEP] B [SEP]"),Zy.forEach(t),Xg.forEach(t),Td.forEach(t),gr.forEach(t),Mp=p(ct),jo=r(ct,"DIV",{class:!0});var wd=l(jo);k(es.$$.fragment,wd),bp=p(wd),Hr=r(wd,"P",{});var Vy=l(Hr);Tp=s(Vy,"Converts a sequence of tokens (string) in a single string."),Vy.forEach(t),wd.forEach(t),wp=p(ct),_t=r(ct,"DIV",{class:!0});var mn=l(_t);k(ts.$$.fragment,mn),kp=p(mn),Or=r(mn,"P",{});var Wy=l(Or);vp=s(Wy,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),Wy.forEach(t),Lp=p(mn),k(Uo.$$.fragment,mn),jp=p(mn),St=r(mn,"P",{});var yr=l(St);Up=s(yr,"If "),Yr=r(yr,"CODE",{});var Qy=l(Yr);Jp=s(Qy,"token_ids_1"),Qy.forEach(t),Cp=s(yr," is "),Kr=r(yr,"CODE",{});var By=l(Kr);Ep=s(By,"None"),By.forEach(t),$p=s(yr,", this method only returns the first portion of the mask (0s)."),yr.forEach(t),mn.forEach(t),Fp=p(ct),Jo=r(ct,"DIV",{class:!0});var kd=l(Jo);k(os.$$.fragment,kd),Ip=p(kd),ns=r(kd,"P",{});var vd=l(ns);zp=s(vd,`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),el=r(vd,"CODE",{});var Gy=l(el);xp=s(Gy,"prepare_for_model"),Gy.forEach(t),Np=s(vd," method."),vd.forEach(t),kd.forEach(t),ct.forEach(t),Zi=p(o),Pt=r(o,"H2",{class:!0});var Ld=l(Pt);Co=r(Ld,"A",{id:!0,class:!0,href:!0});var Dy=l(Co);tl=r(Dy,"SPAN",{});var Xy=l(tl);k(ss.$$.fragment,Xy),Xy.forEach(t),Dy.forEach(t),qp=p(Ld),ol=r(Ld,"SPAN",{});var Sy=l(ol);Ap=s(Sy,"LayoutLMTokenizerFast"),Sy.forEach(t),Ld.forEach(t),Vi=p(o),nt=r(o,"DIV",{class:!0});var At=l(nt);k(as.$$.fragment,At),Rp=p(At),rs=r(At,"P",{});var jd=l(rs);Zp=s(jd,"Construct a \u201Cfast\u201D LayoutLM tokenizer (backed by HuggingFace\u2019s "),nl=r(jd,"EM",{});var Py=l(nl);Vp=s(Py,"tokenizers"),Py.forEach(t),Wp=s(jd," library). Based on WordPiece."),jd.forEach(t),Qp=p(At),ls=r(At,"P",{});var Ud=l(ls);Bp=s(Ud,"This tokenizer inherits from "),Ha=r(Ud,"A",{href:!0});var Hy=l(Ha);Gp=s(Hy,"PreTrainedTokenizerFast"),Hy.forEach(t),Dp=s(Ud,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Ud.forEach(t),Xp=p(At),qt=r(At,"DIV",{class:!0});var _r=l(qt);k(is.$$.fragment,_r),Sp=p(_r),sl=r(_r,"P",{});var Oy=l(sl);Pp=s(Oy,`Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A LayoutLM sequence has the following format:`),Oy.forEach(t),Hp=p(_r),ds=r(_r,"UL",{});var Jd=l(ds);Oa=r(Jd,"LI",{});var Sg=l(Oa);Op=s(Sg,"single sequence: "),al=r(Sg,"CODE",{});var Yy=l(al);Yp=s(Yy,"[CLS] X [SEP]"),Yy.forEach(t),Sg.forEach(t),Kp=p(Jd),Ya=r(Jd,"LI",{});var Pg=l(Ya);eu=s(Pg,"pair of sequences: "),rl=r(Pg,"CODE",{});var Ky=l(rl);tu=s(Ky,"[CLS] A [SEP] B [SEP]"),Ky.forEach(t),Pg.forEach(t),Jd.forEach(t),_r.forEach(t),ou=p(At),Mt=r(At,"DIV",{class:!0});var fn=l(Mt);k(cs.$$.fragment,fn),nu=p(fn),ll=r(fn,"P",{});var e_=l(ll);su=s(e_,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),e_.forEach(t),au=p(fn),k(Eo.$$.fragment,fn),ru=p(fn),Ht=r(fn,"P",{});var Mr=l(Ht);lu=s(Mr,"If "),il=r(Mr,"CODE",{});var t_=l(il);iu=s(t_,"token_ids_1"),t_.forEach(t),du=s(Mr," is "),dl=r(Mr,"CODE",{});var o_=l(dl);cu=s(o_,"None"),o_.forEach(t),pu=s(Mr,", this method only returns the first portion of the mask (0s)."),Mr.forEach(t),fn.forEach(t),At.forEach(t),Wi=p(o),Ot=r(o,"H2",{class:!0});var Cd=l(Ot);$o=r(Cd,"A",{id:!0,class:!0,href:!0});var n_=l($o);cl=r(n_,"SPAN",{});var s_=l(cl);k(ps.$$.fragment,s_),s_.forEach(t),n_.forEach(t),uu=p(Cd),pl=r(Cd,"SPAN",{});var a_=l(pl);hu=s(a_,"LayoutLMModel"),a_.forEach(t),Cd.forEach(t),Qi=p(o),ht=r(o,"DIV",{class:!0});var gn=l(ht);k(us.$$.fragment,gn),mu=p(gn),hs=r(gn,"P",{});var Ed=l(hs);fu=s(Ed,`The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top.
The LayoutLM model was proposed in `),ms=r(Ed,"A",{href:!0,rel:!0});var r_=l(ms);gu=s(r_,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),r_.forEach(t),yu=s(Ed,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Ed.forEach(t),_u=p(gn),fs=r(gn,"P",{});var $d=l(fs);Mu=s($d,"This model is a PyTorch "),gs=r($d,"A",{href:!0,rel:!0});var l_=l(gs);bu=s(l_,"torch.nn.Module"),l_.forEach(t),Tu=s($d,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),$d.forEach(t),wu=p(gn),bt=r(gn,"DIV",{class:!0});var yn=l(bt);k(ys.$$.fragment,yn),ku=p(yn),Yt=r(yn,"P",{});var br=l(Yt);vu=s(br,"The "),Ka=r(br,"A",{href:!0});var i_=l(Ka);Lu=s(i_,"LayoutLMModel"),i_.forEach(t),ju=s(br," forward method, overrides the "),ul=r(br,"CODE",{});var d_=l(ul);Uu=s(d_,"__call__"),d_.forEach(t),Ju=s(br," special method."),br.forEach(t),Cu=p(yn),k(Fo.$$.fragment,yn),Eu=p(yn),k(Io.$$.fragment,yn),yn.forEach(t),gn.forEach(t),Bi=p(o),Kt=r(o,"H2",{class:!0});var Fd=l(Kt);zo=r(Fd,"A",{id:!0,class:!0,href:!0});var c_=l(zo);hl=r(c_,"SPAN",{});var p_=l(hl);k(_s.$$.fragment,p_),p_.forEach(t),c_.forEach(t),$u=p(Fd),ml=r(Fd,"SPAN",{});var u_=l(ml);Fu=s(u_,"LayoutLMForMaskedLM"),u_.forEach(t),Fd.forEach(t),Gi=p(o),mt=r(o,"DIV",{class:!0});var _n=l(mt);k(Ms.$$.fragment,_n),Iu=p(_n),eo=r(_n,"P",{});var Tr=l(eo);zu=s(Tr,"LayoutLM Model with a "),fl=r(Tr,"CODE",{});var h_=l(fl);xu=s(h_,"language modeling"),h_.forEach(t),Nu=s(Tr,` head on top.
The LayoutLM model was proposed in `),bs=r(Tr,"A",{href:!0,rel:!0});var m_=l(bs);qu=s(m_,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),m_.forEach(t),Au=s(Tr,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Tr.forEach(t),Ru=p(_n),Ts=r(_n,"P",{});var Id=l(Ts);Zu=s(Id,"This model is a PyTorch "),ws=r(Id,"A",{href:!0,rel:!0});var f_=l(ws);Vu=s(f_,"torch.nn.Module"),f_.forEach(t),Wu=s(Id,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Id.forEach(t),Qu=p(_n),Tt=r(_n,"DIV",{class:!0});var Mn=l(Tt);k(ks.$$.fragment,Mn),Bu=p(Mn),to=r(Mn,"P",{});var wr=l(to);Gu=s(wr,"The "),er=r(wr,"A",{href:!0});var g_=l(er);Du=s(g_,"LayoutLMForMaskedLM"),g_.forEach(t),Xu=s(wr," forward method, overrides the "),gl=r(wr,"CODE",{});var y_=l(gl);Su=s(y_,"__call__"),y_.forEach(t),Pu=s(wr," special method."),wr.forEach(t),Hu=p(Mn),k(xo.$$.fragment,Mn),Ou=p(Mn),k(No.$$.fragment,Mn),Mn.forEach(t),_n.forEach(t),Di=p(o),oo=r(o,"H2",{class:!0});var zd=l(oo);qo=r(zd,"A",{id:!0,class:!0,href:!0});var __=l(qo);yl=r(__,"SPAN",{});var M_=l(yl);k(vs.$$.fragment,M_),M_.forEach(t),__.forEach(t),Yu=p(zd),_l=r(zd,"SPAN",{});var b_=l(_l);Ku=s(b_,"LayoutLMForSequenceClassification"),b_.forEach(t),zd.forEach(t),Xi=p(o),st=r(o,"DIV",{class:!0});var Rt=l(st);k(Ls.$$.fragment,Rt),eh=p(Rt),js=r(Rt,"P",{});var xd=l(js);th=s(xd,`LayoutLM Model with a sequence classification head on top (a linear layer on top of the pooled output) e.g. for
document image classification tasks such as the `),Us=r(xd,"A",{href:!0,rel:!0});var T_=l(Us);oh=s(T_,"RVL-CDIP"),T_.forEach(t),nh=s(xd," dataset."),xd.forEach(t),sh=p(Rt),Js=r(Rt,"P",{});var Nd=l(Js);ah=s(Nd,"The LayoutLM model was proposed in "),Cs=r(Nd,"A",{href:!0,rel:!0});var w_=l(Cs);rh=s(w_,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),w_.forEach(t),lh=s(Nd,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Nd.forEach(t),ih=p(Rt),Es=r(Rt,"P",{});var qd=l(Es);dh=s(qd,"This model is a PyTorch "),$s=r(qd,"A",{href:!0,rel:!0});var k_=l($s);ch=s(k_,"torch.nn.Module"),k_.forEach(t),ph=s(qd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),qd.forEach(t),uh=p(Rt),wt=r(Rt,"DIV",{class:!0});var bn=l(wt);k(Fs.$$.fragment,bn),hh=p(bn),no=r(bn,"P",{});var kr=l(no);mh=s(kr,"The "),tr=r(kr,"A",{href:!0});var v_=l(tr);fh=s(v_,"LayoutLMForSequenceClassification"),v_.forEach(t),gh=s(kr," forward method, overrides the "),Ml=r(kr,"CODE",{});var L_=l(Ml);yh=s(L_,"__call__"),L_.forEach(t),_h=s(kr," special method."),kr.forEach(t),Mh=p(bn),k(Ao.$$.fragment,bn),bh=p(bn),k(Ro.$$.fragment,bn),bn.forEach(t),Rt.forEach(t),Si=p(o),so=r(o,"H2",{class:!0});var Ad=l(so);Zo=r(Ad,"A",{id:!0,class:!0,href:!0});var j_=l(Zo);bl=r(j_,"SPAN",{});var U_=l(bl);k(Is.$$.fragment,U_),U_.forEach(t),j_.forEach(t),Th=p(Ad),Tl=r(Ad,"SPAN",{});var J_=l(Tl);wh=s(J_,"LayoutLMForTokenClassification"),J_.forEach(t),Ad.forEach(t),Pi=p(o),at=r(o,"DIV",{class:!0});var Zt=l(at);k(zs.$$.fragment,Zt),kh=p(Zt),ao=r(Zt,"P",{});var vr=l(ao);vh=s(vr,`LayoutLM Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
sequence labeling (information extraction) tasks such as the `),xs=r(vr,"A",{href:!0,rel:!0});var C_=l(xs);Lh=s(C_,"FUNSD"),C_.forEach(t),jh=s(vr,`
dataset and the `),Ns=r(vr,"A",{href:!0,rel:!0});var E_=l(Ns);Uh=s(E_,"SROIE"),E_.forEach(t),Jh=s(vr," dataset."),vr.forEach(t),Ch=p(Zt),qs=r(Zt,"P",{});var Rd=l(qs);Eh=s(Rd,"The LayoutLM model was proposed in "),As=r(Rd,"A",{href:!0,rel:!0});var $_=l(As);$h=s($_,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),$_.forEach(t),Fh=s(Rd,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Rd.forEach(t),Ih=p(Zt),Rs=r(Zt,"P",{});var Zd=l(Rs);zh=s(Zd,"This model is a PyTorch "),Zs=r(Zd,"A",{href:!0,rel:!0});var F_=l(Zs);xh=s(F_,"torch.nn.Module"),F_.forEach(t),Nh=s(Zd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Zd.forEach(t),qh=p(Zt),kt=r(Zt,"DIV",{class:!0});var Tn=l(kt);k(Vs.$$.fragment,Tn),Ah=p(Tn),ro=r(Tn,"P",{});var Lr=l(ro);Rh=s(Lr,"The "),or=r(Lr,"A",{href:!0});var I_=l(or);Zh=s(I_,"LayoutLMForTokenClassification"),I_.forEach(t),Vh=s(Lr," forward method, overrides the "),wl=r(Lr,"CODE",{});var z_=l(wl);Wh=s(z_,"__call__"),z_.forEach(t),Qh=s(Lr," special method."),Lr.forEach(t),Bh=p(Tn),k(Vo.$$.fragment,Tn),Gh=p(Tn),k(Wo.$$.fragment,Tn),Tn.forEach(t),Zt.forEach(t),Hi=p(o),lo=r(o,"H2",{class:!0});var Vd=l(lo);Qo=r(Vd,"A",{id:!0,class:!0,href:!0});var x_=l(Qo);kl=r(x_,"SPAN",{});var N_=l(kl);k(Ws.$$.fragment,N_),N_.forEach(t),x_.forEach(t),Dh=p(Vd),vl=r(Vd,"SPAN",{});var q_=l(vl);Xh=s(q_,"LayoutLMForQuestionAnswering"),q_.forEach(t),Vd.forEach(t),Oi=p(o),rt=r(o,"DIV",{class:!0});var Vt=l(rt);k(Qs.$$.fragment,Vt),Sh=p(Vt),zt=r(Vt,"P",{});var wn=l(zt);Ph=s(wn,`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),Bs=r(wn,"A",{href:!0,rel:!0});var A_=l(Bs);Hh=s(A_,"DocVQA"),A_.forEach(t),Oh=s(wn," (a linear layer on top of the final hidden-states output to compute "),Ll=r(wn,"CODE",{});var R_=l(Ll);Yh=s(R_,"span start logits"),R_.forEach(t),Kh=s(wn," and "),jl=r(wn,"CODE",{});var Z_=l(jl);em=s(Z_,"span end logits"),Z_.forEach(t),tm=s(wn,")."),wn.forEach(t),om=p(Vt),Gs=r(Vt,"P",{});var Wd=l(Gs);nm=s(Wd,"The LayoutLM model was proposed in "),Ds=r(Wd,"A",{href:!0,rel:!0});var V_=l(Ds);sm=s(V_,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),V_.forEach(t),am=s(Wd,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Wd.forEach(t),rm=p(Vt),Xs=r(Vt,"P",{});var Qd=l(Xs);lm=s(Qd,"This model is a PyTorch "),Ss=r(Qd,"A",{href:!0,rel:!0});var W_=l(Ss);im=s(W_,"torch.nn.Module"),W_.forEach(t),dm=s(Qd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Qd.forEach(t),cm=p(Vt),dt=r(Vt,"DIV",{class:!0});var Wt=l(dt);k(Ps.$$.fragment,Wt),pm=p(Wt),Ne=r(Wt,"P",{});var He=l(Ne);um=s(He,"start_positions ("),Ul=r(He,"CODE",{});var Q_=l(Ul);hm=s(Q_,"torch.LongTensor"),Q_.forEach(t),mm=s(He," of shape "),Jl=r(He,"CODE",{});var B_=l(Jl);fm=s(B_,"(batch_size,)"),B_.forEach(t),gm=s(He,", "),Cl=r(He,"EM",{});var G_=l(Cl);ym=s(G_,"optional"),G_.forEach(t),_m=s(He,`):
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 (`),El=r(He,"CODE",{});var D_=l(El);Mm=s(D_,"sequence_length"),D_.forEach(t),bm=s(He,`). Position outside of the sequence
are not taken into account for computing the loss.
end_positions (`),$l=r(He,"CODE",{});var X_=l($l);Tm=s(X_,"torch.LongTensor"),X_.forEach(t),wm=s(He," of shape "),Fl=r(He,"CODE",{});var S_=l(Fl);km=s(S_,"(batch_size,)"),S_.forEach(t),vm=s(He,", "),Il=r(He,"EM",{});var P_=l(Il);Lm=s(P_,"optional"),P_.forEach(t),jm=s(He,`):
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 (`),zl=r(He,"CODE",{});var H_=l(zl);Um=s(H_,"sequence_length"),H_.forEach(t),Jm=s(He,`). Position outside of the sequence
are not taken into account for computing the loss.`),He.forEach(t),Cm=p(Wt),xl=r(Wt,"P",{});var O_=l(xl);Em=s(O_,"Example:"),O_.forEach(t),$m=p(Wt),Nl=r(Wt,"P",{});var Y_=l(Nl);Fm=s(Y_,`In the example below, we prepare a question + context pair for the LayoutLM model. 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).`),Y_.forEach(t),Im=p(Wt),k(Bo.$$.fragment,Wt),Wt.forEach(t),Vt.forEach(t),Yi=p(o),io=r(o,"H2",{class:!0});var Bd=l(io);Go=r(Bd,"A",{id:!0,class:!0,href:!0});var K_=l(Go);ql=r(K_,"SPAN",{});var eM=l(ql);k(Hs.$$.fragment,eM),eM.forEach(t),K_.forEach(t),zm=p(Bd),Al=r(Bd,"SPAN",{});var tM=l(Al);xm=s(tM,"TFLayoutLMModel"),tM.forEach(t),Bd.forEach(t),Ki=p(o),Oe=r(o,"DIV",{class:!0});var Ct=l(Oe);k(Os.$$.fragment,Ct),Nm=p(Ct),Rl=r(Ct,"P",{});var oM=l(Rl);qm=s(oM,"The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top."),oM.forEach(t),Am=p(Ct),Ys=r(Ct,"P",{});var Gd=l(Ys);Rm=s(Gd,"This model inherits from "),nr=r(Gd,"A",{href:!0});var nM=l(nr);Zm=s(nM,"TFPreTrainedModel"),nM.forEach(t),Vm=s(Gd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Gd.forEach(t),Wm=p(Ct),Ks=r(Ct,"P",{});var Dd=l(Ks);Qm=s(Dd,"This model is also a "),ea=r(Dd,"A",{href:!0,rel:!0});var sM=l(ea);Bm=s(sM,"tf.keras.Model"),sM.forEach(t),Gm=s(Dd,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Dd.forEach(t),Dm=p(Ct),k(Do.$$.fragment,Ct),Xm=p(Ct),vt=r(Ct,"DIV",{class:!0});var kn=l(vt);k(ta.$$.fragment,kn),Sm=p(kn),co=r(kn,"P",{});var jr=l(co);Pm=s(jr,"The "),sr=r(jr,"A",{href:!0});var aM=l(sr);Hm=s(aM,"TFLayoutLMModel"),aM.forEach(t),Om=s(jr," forward method, overrides the "),Zl=r(jr,"CODE",{});var rM=l(Zl);Ym=s(rM,"__call__"),rM.forEach(t),Km=s(jr," special method."),jr.forEach(t),ef=p(kn),k(Xo.$$.fragment,kn),tf=p(kn),k(So.$$.fragment,kn),kn.forEach(t),Ct.forEach(t),ed=p(o),po=r(o,"H2",{class:!0});var Xd=l(po);Po=r(Xd,"A",{id:!0,class:!0,href:!0});var lM=l(Po);Vl=r(lM,"SPAN",{});var iM=l(Vl);k(oa.$$.fragment,iM),iM.forEach(t),lM.forEach(t),of=p(Xd),Wl=r(Xd,"SPAN",{});var dM=l(Wl);nf=s(dM,"TFLayoutLMForMaskedLM"),dM.forEach(t),Xd.forEach(t),td=p(o),Ye=r(o,"DIV",{class:!0});var Et=l(Ye);k(na.$$.fragment,Et),sf=p(Et),sa=r(Et,"P",{});var Sd=l(sa);af=s(Sd,"LayoutLM Model with a "),Ql=r(Sd,"CODE",{});var cM=l(Ql);rf=s(cM,"language modeling"),cM.forEach(t),lf=s(Sd," head on top."),Sd.forEach(t),df=p(Et),aa=r(Et,"P",{});var Pd=l(aa);cf=s(Pd,"This model inherits from "),ar=r(Pd,"A",{href:!0});var pM=l(ar);pf=s(pM,"TFPreTrainedModel"),pM.forEach(t),uf=s(Pd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Pd.forEach(t),hf=p(Et),ra=r(Et,"P",{});var Hd=l(ra);mf=s(Hd,"This model is also a "),la=r(Hd,"A",{href:!0,rel:!0});var uM=l(la);ff=s(uM,"tf.keras.Model"),uM.forEach(t),gf=s(Hd,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Hd.forEach(t),yf=p(Et),k(Ho.$$.fragment,Et),_f=p(Et),Lt=r(Et,"DIV",{class:!0});var vn=l(Lt);k(ia.$$.fragment,vn),Mf=p(vn),uo=r(vn,"P",{});var Ur=l(uo);bf=s(Ur,"The "),rr=r(Ur,"A",{href:!0});var hM=l(rr);Tf=s(hM,"TFLayoutLMForMaskedLM"),hM.forEach(t),wf=s(Ur," forward method, overrides the "),Bl=r(Ur,"CODE",{});var mM=l(Bl);kf=s(mM,"__call__"),mM.forEach(t),vf=s(Ur," special method."),Ur.forEach(t),Lf=p(vn),k(Oo.$$.fragment,vn),jf=p(vn),k(Yo.$$.fragment,vn),vn.forEach(t),Et.forEach(t),od=p(o),ho=r(o,"H2",{class:!0});var Od=l(ho);Ko=r(Od,"A",{id:!0,class:!0,href:!0});var fM=l(Ko);Gl=r(fM,"SPAN",{});var gM=l(Gl);k(da.$$.fragment,gM),gM.forEach(t),fM.forEach(t),Uf=p(Od),Dl=r(Od,"SPAN",{});var yM=l(Dl);Jf=s(yM,"TFLayoutLMForSequenceClassification"),yM.forEach(t),Od.forEach(t),nd=p(o),Ke=r(o,"DIV",{class:!0});var $t=l(Ke);k(ca.$$.fragment,$t),Cf=p($t),Xl=r($t,"P",{});var _M=l(Xl);Ef=s(_M,`LayoutLM Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),_M.forEach(t),$f=p($t),pa=r($t,"P",{});var Yd=l(pa);Ff=s(Yd,"This model inherits from "),lr=r(Yd,"A",{href:!0});var MM=l(lr);If=s(MM,"TFPreTrainedModel"),MM.forEach(t),zf=s(Yd,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Yd.forEach(t),xf=p($t),ua=r($t,"P",{});var Kd=l(ua);Nf=s(Kd,"This model is also a "),ha=r(Kd,"A",{href:!0,rel:!0});var bM=l(ha);qf=s(bM,"tf.keras.Model"),bM.forEach(t),Af=s(Kd,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),Kd.forEach(t),Rf=p($t),k(en.$$.fragment,$t),Zf=p($t),jt=r($t,"DIV",{class:!0});var Ln=l(jt);k(ma.$$.fragment,Ln),Vf=p(Ln),mo=r(Ln,"P",{});var Jr=l(mo);Wf=s(Jr,"The "),ir=r(Jr,"A",{href:!0});var TM=l(ir);Qf=s(TM,"TFLayoutLMForSequenceClassification"),TM.forEach(t),Bf=s(Jr," forward method, overrides the "),Sl=r(Jr,"CODE",{});var wM=l(Sl);Gf=s(wM,"__call__"),wM.forEach(t),Df=s(Jr," special method."),Jr.forEach(t),Xf=p(Ln),k(tn.$$.fragment,Ln),Sf=p(Ln),k(on.$$.fragment,Ln),Ln.forEach(t),$t.forEach(t),sd=p(o),fo=r(o,"H2",{class:!0});var ec=l(fo);nn=r(ec,"A",{id:!0,class:!0,href:!0});var kM=l(nn);Pl=r(kM,"SPAN",{});var vM=l(Pl);k(fa.$$.fragment,vM),vM.forEach(t),kM.forEach(t),Pf=p(ec),Hl=r(ec,"SPAN",{});var LM=l(Hl);Hf=s(LM,"TFLayoutLMForTokenClassification"),LM.forEach(t),ec.forEach(t),ad=p(o),et=r(o,"DIV",{class:!0});var Ft=l(et);k(ga.$$.fragment,Ft),Of=p(Ft),Ol=r(Ft,"P",{});var jM=l(Ol);Yf=s(jM,`LayoutLM Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),jM.forEach(t),Kf=p(Ft),ya=r(Ft,"P",{});var tc=l(ya);eg=s(tc,"This model inherits from "),dr=r(tc,"A",{href:!0});var UM=l(dr);tg=s(UM,"TFPreTrainedModel"),UM.forEach(t),og=s(tc,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),tc.forEach(t),ng=p(Ft),_a=r(Ft,"P",{});var oc=l(_a);sg=s(oc,"This model is also a "),Ma=r(oc,"A",{href:!0,rel:!0});var JM=l(Ma);ag=s(JM,"tf.keras.Model"),JM.forEach(t),rg=s(oc,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),oc.forEach(t),lg=p(Ft),k(sn.$$.fragment,Ft),ig=p(Ft),Ut=r(Ft,"DIV",{class:!0});var jn=l(Ut);k(ba.$$.fragment,jn),dg=p(jn),go=r(jn,"P",{});var Cr=l(go);cg=s(Cr,"The "),cr=r(Cr,"A",{href:!0});var CM=l(cr);pg=s(CM,"TFLayoutLMForTokenClassification"),CM.forEach(t),ug=s(Cr," forward method, overrides the "),Yl=r(Cr,"CODE",{});var EM=l(Yl);hg=s(EM,"__call__"),EM.forEach(t),mg=s(Cr," special method."),Cr.forEach(t),fg=p(jn),k(an.$$.fragment,jn),gg=p(jn),k(rn.$$.fragment,jn),jn.forEach(t),Ft.forEach(t),rd=p(o),yo=r(o,"H2",{class:!0});var nc=l(yo);ln=r(nc,"A",{id:!0,class:!0,href:!0});var $M=l(ln);Kl=r($M,"SPAN",{});var FM=l(Kl);k(Ta.$$.fragment,FM),FM.forEach(t),$M.forEach(t),yg=p(nc),ei=r(nc,"SPAN",{});var IM=l(ei);_g=s(IM,"TFLayoutLMForQuestionAnswering"),IM.forEach(t),nc.forEach(t),ld=p(o),tt=r(o,"DIV",{class:!0});var It=l(tt);k(wa.$$.fragment,It),Mg=p(It),xt=r(It,"P",{});var Un=l(xt);bg=s(Un,`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),ka=r(Un,"A",{href:!0,rel:!0});var zM=l(ka);Tg=s(zM,"DocVQA"),zM.forEach(t),wg=s(Un," (a linear layer on top of the final hidden-states output to compute "),ti=r(Un,"CODE",{});var xM=l(ti);kg=s(xM,"span start logits"),xM.forEach(t),vg=s(Un," and "),oi=r(Un,"CODE",{});var NM=l(oi);Lg=s(NM,"span end logits"),NM.forEach(t),jg=s(Un,")."),Un.forEach(t),Ug=p(It),va=r(It,"P",{});var sc=l(va);Jg=s(sc,"This model inherits from "),pr=r(sc,"A",{href:!0});var qM=l(pr);Cg=s(qM,"TFPreTrainedModel"),qM.forEach(t),Eg=s(sc,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),sc.forEach(t),$g=p(It),La=r(It,"P",{});var ac=l(La);Fg=s(ac,"This model is also a "),ja=r(ac,"A",{href:!0,rel:!0});var AM=l(ja);Ig=s(AM,"tf.keras.Model"),AM.forEach(t),zg=s(ac,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),ac.forEach(t),xg=p(It),k(dn.$$.fragment,It),Ng=p(It),Jt=r(It,"DIV",{class:!0});var Jn=l(Jt);k(Ua.$$.fragment,Jn),qg=p(Jn),_o=r(Jn,"P",{});var Er=l(_o);Ag=s(Er,"The "),ur=r(Er,"A",{href:!0});var RM=l(ur);Rg=s(RM,"TFLayoutLMForQuestionAnswering"),RM.forEach(t),Zg=s(Er," forward method, overrides the "),ni=r(Er,"CODE",{});var ZM=l(ni);Vg=s(ZM,"__call__"),ZM.forEach(t),Wg=s(Er," special method."),Er.forEach(t),Qg=p(Jn),k(cn.$$.fragment,Jn),Bg=p(Jn),k(pn.$$.fragment,Jn),Jn.forEach(t),It.forEach(t),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(bb)),u(g,"id","layoutlm"),u(g,"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"),u(g,"href","#layoutlm"),u(f,"class","relative group"),u(W,"id","Overview"),u(T,"id","overview"),u(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"),u(T,"href","#overview"),u(G,"class","relative group"),u(le,"href","https://arxiv.org/abs/1912.13318"),u(le,"rel","nofollow"),u(ie,"href","https://guillaumejaume.github.io/FUNSD/"),u(ie,"rel","nofollow"),u(ce,"href","https://rrc.cvc.uab.es/?ch=13"),u(ce,"rel","nofollow"),u(ue,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),u(ue,"rel","nofollow"),u(te,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMModel.forward"),u(xe,"href","https://github.com/tesseract-ocr/tesseract"),u(xe,"rel","nofollow"),u(q,"href","https://pypi.org/project/pytesseract/"),u(q,"rel","nofollow"),u(bo,"id","resources"),u(bo,"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"),u(bo,"href","#resources"),u(Qt,"class","relative group"),u(In,"href","https://www.philschmid.de/fine-tuning-layoutlm-keras"),u(In,"rel","nofollow"),u(xn,"href","https://www.philschmid.de/fine-tuning-layoutlm"),u(xn,"rel","nofollow"),u(qn,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLM/Add_image_embeddings_to_LayoutLM.ipynb"),u(qn,"rel","nofollow"),u(Na,"href","../tasks/document_question_answering"),u(Zn,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLM/Fine_tuning_LayoutLMForSequenceClassification_on_RVL_CDIP.ipynb"),u(Zn,"rel","nofollow"),u(qa,"href","../tasks/sequence_classification"),u(Qn,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/LayoutLM/Fine_tuning_LayoutLMForTokenClassification_on_FUNSD.ipynb"),u(Qn,"rel","nofollow"),u(Aa,"href","../tasks/token_classification"),u(Va,"href","../tasks/masked_language_modeling"),u(Gn,"href","https://www.philschmid.de/inference-endpoints-layoutlm"),u(Gn,"rel","nofollow"),u(ko,"id","transformers.LayoutLMConfig"),u(ko,"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"),u(ko,"href","#transformers.LayoutLMConfig"),u(Bt,"class","relative group"),u(Ba,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMModel"),u(Sn,"href","https://huggingface.co/microsoft/layoutlm-base-uncased"),u(Sn,"rel","nofollow"),u(Ga,"href","/docs/transformers/main/en/model_doc/bert#transformers.BertConfig"),u(Da,"href","/docs/transformers/main/en/model_doc/bert#transformers.BertConfig"),u(ut,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Lo,"id","transformers.LayoutLMTokenizer"),u(Lo,"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"),u(Lo,"href","#transformers.LayoutLMTokenizer"),u(Xt,"class","relative group"),u(Xa,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),u(Nt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(jo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(_t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Jo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ze,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Co,"id","transformers.LayoutLMTokenizerFast"),u(Co,"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"),u(Co,"href","#transformers.LayoutLMTokenizerFast"),u(Pt,"class","relative group"),u(Ha,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),u(qt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Mt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(nt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u($o,"id","transformers.LayoutLMModel"),u($o,"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"),u($o,"href","#transformers.LayoutLMModel"),u(Ot,"class","relative group"),u(ms,"href","https://arxiv.org/abs/1912.13318"),u(ms,"rel","nofollow"),u(gs,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(gs,"rel","nofollow"),u(Ka,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMModel"),u(bt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ht,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(zo,"id","transformers.LayoutLMForMaskedLM"),u(zo,"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"),u(zo,"href","#transformers.LayoutLMForMaskedLM"),u(Kt,"class","relative group"),u(bs,"href","https://arxiv.org/abs/1912.13318"),u(bs,"rel","nofollow"),u(ws,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(ws,"rel","nofollow"),u(er,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMForMaskedLM"),u(Tt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(mt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(qo,"id","transformers.LayoutLMForSequenceClassification"),u(qo,"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"),u(qo,"href","#transformers.LayoutLMForSequenceClassification"),u(oo,"class","relative group"),u(Us,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),u(Us,"rel","nofollow"),u(Cs,"href","https://arxiv.org/abs/1912.13318"),u(Cs,"rel","nofollow"),u($s,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u($s,"rel","nofollow"),u(tr,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMForSequenceClassification"),u(wt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(st,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Zo,"id","transformers.LayoutLMForTokenClassification"),u(Zo,"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"),u(Zo,"href","#transformers.LayoutLMForTokenClassification"),u(so,"class","relative group"),u(xs,"href","https://guillaumejaume.github.io/FUNSD/"),u(xs,"rel","nofollow"),u(Ns,"href","https://rrc.cvc.uab.es/?ch=13"),u(Ns,"rel","nofollow"),u(As,"href","https://arxiv.org/abs/1912.13318"),u(As,"rel","nofollow"),u(Zs,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Zs,"rel","nofollow"),u(or,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.LayoutLMForTokenClassification"),u(kt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(at,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Qo,"id","transformers.LayoutLMForQuestionAnswering"),u(Qo,"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"),u(Qo,"href","#transformers.LayoutLMForQuestionAnswering"),u(lo,"class","relative group"),u(Bs,"href","https://rrc.cvc.uab.es/?ch=17"),u(Bs,"rel","nofollow"),u(Ds,"href","https://arxiv.org/abs/1912.13318"),u(Ds,"rel","nofollow"),u(Ss,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Ss,"rel","nofollow"),u(dt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(rt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Go,"id","transformers.TFLayoutLMModel"),u(Go,"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"),u(Go,"href","#transformers.TFLayoutLMModel"),u(io,"class","relative group"),u(nr,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(ea,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(ea,"rel","nofollow"),u(sr,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.TFLayoutLMModel"),u(vt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Po,"id","transformers.TFLayoutLMForMaskedLM"),u(Po,"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"),u(Po,"href","#transformers.TFLayoutLMForMaskedLM"),u(po,"class","relative group"),u(ar,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(la,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(la,"rel","nofollow"),u(rr,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.TFLayoutLMForMaskedLM"),u(Lt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ko,"id","transformers.TFLayoutLMForSequenceClassification"),u(Ko,"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"),u(Ko,"href","#transformers.TFLayoutLMForSequenceClassification"),u(ho,"class","relative group"),u(lr,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(ha,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(ha,"rel","nofollow"),u(ir,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.TFLayoutLMForSequenceClassification"),u(jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(nn,"id","transformers.TFLayoutLMForTokenClassification"),u(nn,"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"),u(nn,"href","#transformers.TFLayoutLMForTokenClassification"),u(fo,"class","relative group"),u(dr,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(Ma,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(Ma,"rel","nofollow"),u(cr,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.TFLayoutLMForTokenClassification"),u(Ut,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(et,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ln,"id","transformers.TFLayoutLMForQuestionAnswering"),u(ln,"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"),u(ln,"href","#transformers.TFLayoutLMForQuestionAnswering"),u(yo,"class","relative group"),u(ka,"href","https://rrc.cvc.uab.es/?ch=17"),u(ka,"rel","nofollow"),u(pr,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(ja,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(ja,"rel","nofollow"),u(ur,"href","/docs/transformers/main/en/model_doc/layoutlm#transformers.TFLayoutLMForQuestionAnswering"),u(Jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(tt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,y){e(document.head,d),m(o,b,y),m(o,f,y),e(f,g),e(g,M),v(i,M,null),e(f,h),e(f,E),e(E,Le),m(o,ye,y),m(o,W,y),m(o,_e,y),m(o,G,y),e(G,T),e(T,he),v(R,he,null),e(G,je),e(G,me),e(me,D),m(o,Me,y),m(o,se,y),e(se,X),e(se,le),e(le,Ue),e(se,S),m(o,be,y),m(o,oe,y),e(oe,Z),e(Z,Je),e(Z,ie),e(ie,ae),e(Z,$),e(oe,I),e(oe,de),e(de,P),e(de,ce),e(ce,Ce),e(de,H),e(oe,Ee),e(oe,pe),e(pe,z),e(pe,ue),e(ue,O),e(pe,$e),m(o,Te,y),m(o,Q,y),e(Q,Fe),m(o,we,y),m(o,A,y),e(A,fe),e(fe,Y),m(o,ke,y),m(o,ee,y),e(ee,x),m(o,ve,y),m(o,N,y),e(N,B),e(B,Ie),e(B,_),e(_,J),e(B,Ve),e(B,te),e(te,We),e(B,Qe),e(B,C),e(C,Be),e(B,Ge),e(B,xe),e(xe,De),e(B,Xe),e(B,q),e(q,K),e(B,Se),m(o,Ae,y),v(V,o,y),m(o,Re,y),m(o,ge,y),e(ge,ze),e(ge,qe),e(qe,re),e(ge,Pe),e(ge,$r),e($r,rc),e(ge,lc),m(o,ki,y),v(Cn,o,y),m(o,vi,y),m(o,Qt,y),e(Qt,bo),e(bo,Fr),v(En,Fr,null),e(Qt,ic),e(Qt,Ir),e(Ir,dc),m(o,Li,y),m(o,za,y),e(za,cc),m(o,ji,y),v($n,o,y),m(o,Ui,y),m(o,yt,y),e(yt,zr),e(zr,Fn),e(Fn,pc),e(Fn,In),e(In,uc),e(Fn,hc),e(yt,mc),e(yt,xr),e(xr,zn),e(zn,fc),e(zn,xn),e(xn,gc),e(zn,yc),e(yt,_c),e(yt,Nr),e(Nr,Nn),e(Nn,Mc),e(Nn,qn),e(qn,bc),e(Nn,Tc),e(yt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,_u),e(ht,fs),e(fs,Mu),e(fs,gs),e(gs,bu),e(fs,Tu),e(ht,wu),e(ht,bt),v(ys,bt,null),e(bt,ku),e(bt,Yt),e(Yt,vu),e(Yt,Ka),e(Ka,Lu),e(Yt,ju),e(Yt,ul),e(ul,Uu),e(Yt,Ju),e(bt,Cu),v(Fo,bt,null),e(bt,Eu),v(Io,bt,null),m(o,Bi,y),m(o,Kt,y),e(Kt,zo),e(zo,hl),v(_s,hl,null),e(Kt,$u),e(Kt,ml),e(ml,Fu),m(o,Gi,y),m(o,mt,y),v(Ms,mt,null),e(mt,Iu),e(mt,eo),e(eo,zu),e(eo,fl),e(fl,xu),e(eo,Nu),e(eo,bs),e(bs,qu),e(eo,Au),e(mt,Ru),e(mt,Ts),e(Ts,Zu),e(Ts,ws),e(ws,Vu),e(Ts,Wu),e(mt,Qu),e(mt,Tt),v(ks,Tt,null),e(Tt,Bu),e(Tt,to),e(to,Gu),e(to,er),e(er,Du),e(to,Xu),e(to,gl),e(gl,Su),e(to,Pu),e(Tt,Hu),v(xo,Tt,null),e(Tt,Ou),v(No,Tt,null),m(o,Di,y),m(o,oo,y),e(oo,qo),e(qo,yl),v(vs,yl,null),e(oo,Yu),e(oo,_l),e(_l,Ku),m(o,Xi,y),m(o,st,y),v(Ls,st,null),e(st,eh),e(st,js),e(js,th),e(js,Us),e(Us,oh),e(js,nh),e(st,sh),e(st,Js),e(Js,ah),e(Js,Cs),e(Cs,rh),e(Js,lh),e(st,ih),e(st,Es),e(Es,dh),e(Es,$s),e($s,ch),e(Es,ph),e(st,uh),e(st,wt),v(Fs,wt,null),e(wt,hh),e(wt,no),e(no,mh),e(no,tr),e(tr,fh),e(no,gh),e(no,Ml),e(Ml,yh),e(no,_h),e(wt,Mh),v(Ao,wt,null),e(wt,bh),v(Ro,wt,null),m(o,Si,y),m(o,so,y),e(so,Zo),e(Zo,bl),v(Is,bl,null),e(so,Th),e(so,Tl),e(Tl,wh),m(o,Pi,y),m(o,at,y),v(zs,at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Zf),e(Ke,jt),v(ma,jt,null),e(jt,Vf),e(jt,mo),e(mo,Wf),e(mo,ir),e(ir,Qf),e(mo,Bf),e(mo,Sl),e(Sl,Gf),e(mo,Df),e(jt,Xf),v(tn,jt,null),e(jt,Sf),v(on,jt,null),m(o,sd,y),m(o,fo,y),e(fo,nn),e(nn,Pl),v(fa,Pl,null),e(fo,Pf),e(fo,Hl),e(Hl,Hf),m(o,ad,y),m(o,et,y),v(ga,et,null),e(et,Of),e(et,Ol),e(Ol,Yf),e(et,Kf),e(et,ya),e(ya,eg),e(ya,dr),e(dr,tg),e(ya,og),e(et,ng),e(et,_a),e(_a,sg),e(_a,Ma),e(Ma,ag),e(_a,rg),e(et,lg),v(sn,et,null),e(et,ig),e(et,Ut),v(ba,Ut,null),e(Ut,dg),e(Ut,go),e(go,cg),e(go,cr),e(cr,pg),e(go,ug),e(go,Yl),e(Yl,hg),e(go,mg),e(Ut,fg),v(an,Ut,null),e(Ut,gg),v(rn,Ut,null),m(o,rd,y),m(o,yo,y),e(yo,ln),e(ln,Kl),v(Ta,Kl,null),e(yo,yg),e(yo,ei),e(ei,_g),m(o,ld,y),m(o,tt,y),v(wa,tt,null),e(tt,Mg),e(tt,xt),e(xt,bg),e(xt,ka),e(ka,Tg),e(xt,wg),e(xt,ti),e(ti,kg),e(xt,vg),e(xt,oi),e(oi,Lg),e(xt,jg),e(tt,Ug),e(tt,va),e(va,Jg),e(va,pr),e(pr,Cg),e(va,Eg),e(tt,$g),e(tt,La),e(La,Fg),e(La,ja),e(ja,Ig),e(La,zg),e(tt,xg),v(dn,tt,null),e(tt,Ng),e(tt,Jt),v(Ua,Jt,null),e(Jt,qg),e(Jt,_o),e(_o,Ag),e(_o,ur),e(ur,Rg),e(_o,Zg),e(_o,ni),e(ni,Vg),e(_o,Wg),e(Jt,Qg),v(cn,Jt,null),e(Jt,Bg),v(pn,Jt,null),id=!0},p(o,[y]){const Ja={};y&2&&(Ja.$$scope={dirty:y,ctx:o}),vo.$set(Ja);const si={};y&2&&(si.$$scope={dirty:y,ctx:o}),Uo.$set(si);const ai={};y&2&&(ai.$$scope={dirty:y,ctx:o}),Eo.$set(ai);const ri={};y&2&&(ri.$$scope={dirty:y,ctx:o}),Fo.$set(ri);const Ca={};y&2&&(Ca.$$scope={dirty:y,ctx:o}),Io.$set(Ca);const li={};y&2&&(li.$$scope={dirty:y,ctx:o}),xo.$set(li);const ii={};y&2&&(ii.$$scope={dirty:y,ctx:o}),No.$set(ii);const di={};y&2&&(di.$$scope={dirty:y,ctx:o}),Ao.$set(di);const Ea={};y&2&&(Ea.$$scope={dirty:y,ctx:o}),Ro.$set(Ea);const ci={};y&2&&(ci.$$scope={dirty:y,ctx:o}),Vo.$set(ci);const Mo={};y&2&&(Mo.$$scope={dirty:y,ctx:o}),Wo.$set(Mo);const $a={};y&2&&($a.$$scope={dirty:y,ctx:o}),Bo.$set($a);const pi={};y&2&&(pi.$$scope={dirty:y,ctx:o}),Do.$set(pi);const Fa={};y&2&&(Fa.$$scope={dirty:y,ctx:o}),Xo.$set(Fa);const ui={};y&2&&(ui.$$scope={dirty:y,ctx:o}),So.$set(ui);const Ia={};y&2&&(Ia.$$scope={dirty:y,ctx:o}),Ho.$set(Ia);const hi={};y&2&&(hi.$$scope={dirty:y,ctx:o}),Oo.$set(hi);const mi={};y&2&&(mi.$$scope={dirty:y,ctx:o}),Yo.$set(mi);const fi={};y&2&&(fi.$$scope={dirty:y,ctx:o}),en.$set(fi);const gi={};y&2&&(gi.$$scope={dirty:y,ctx:o}),tn.$set(gi);const yi={};y&2&&(yi.$$scope={dirty:y,ctx:o}),on.$set(yi);const _i={};y&2&&(_i.$$scope={dirty:y,ctx:o}),sn.$set(_i);const lt={};y&2&&(lt.$$scope={dirty:y,ctx:o}),an.$set(lt);const Mi={};y&2&&(Mi.$$scope={dirty:y,ctx:o}),rn.$set(Mi);const bi={};y&2&&(bi.$$scope={dirty:y,ctx:o}),dn.$set(bi);const Ti={};y&2&&(Ti.$$scope={dirty:y,ctx:o}),cn.$set(Ti);const wi={};y&2&&(wi.$$scope={dirty:y,ctx:o}),pn.$set(wi)},i(o){id||(L(i.$$.fragment,o),L(R.$$.fragment,o),L(V.$$.fragment,o),L(Cn.$$.fragment,o),L(En.$$.fragment,o),L($n.$$.fragment,o),L(An.$$.fragment,o),L(Vn.$$.fragment,o),L(Dn.$$.fragment,o),L(Xn.$$.fragment,o),L(vo.$$.fragment,o),L(Pn.$$.fragment,o),L(Hn.$$.fragment,o),L(Yn.$$.fragment,o),L(es.$$.fragment,o),L(ts.$$.fragment,o),L(Uo.$$.fragment,o),L(os.$$.fragment,o),L(ss.$$.fragment,o),L(as.$$.fragment,o),L(is.$$.fragment,o),L(cs.$$.fragment,o),L(Eo.$$.fragment,o),L(ps.$$.fragment,o),L(us.$$.fragment,o),L(ys.$$.fragment,o),L(Fo.$$.fragment,o),L(Io.$$.fragment,o),L(_s.$$.fragment,o),L(Ms.$$.fragment,o),L(ks.$$.fragment,o),L(xo.$$.fragment,o),L(No.$$.fragment,o),L(vs.$$.fragment,o),L(Ls.$$.fragment,o),L(Fs.$$.fragment,o),L(Ao.$$.fragment,o),L(Ro.$$.fragment,o),L(Is.$$.fragment,o),L(zs.$$.fragment,o),L(Vs.$$.fragment,o),L(Vo.$$.fragment,o),L(Wo.$$.fragment,o),L(Ws.$$.fragment,o),L(Qs.$$.fragment,o),L(Ps.$$.fragment,o),L(Bo.$$.fragment,o),L(Hs.$$.fragment,o),L(Os.$$.fragment,o),L(Do.$$.fragment,o),L(ta.$$.fragment,o),L(Xo.$$.fragment,o),L(So.$$.fragment,o),L(oa.$$.fragment,o),L(na.$$.fragment,o),L(Ho.$$.fragment,o),L(ia.$$.fragment,o),L(Oo.$$.fragment,o),L(Yo.$$.fragment,o),L(da.$$.fragment,o),L(ca.$$.fragment,o),L(en.$$.fragment,o),L(ma.$$.fragment,o),L(tn.$$.fragment,o),L(on.$$.fragment,o),L(fa.$$.fragment,o),L(ga.$$.fragment,o),L(sn.$$.fragment,o),L(ba.$$.fragment,o),L(an.$$.fragment,o),L(rn.$$.fragment,o),L(Ta.$$.fragment,o),L(wa.$$.fragment,o),L(dn.$$.fragment,o),L(Ua.$$.fragment,o),L(cn.$$.fragment,o),L(pn.$$.fragment,o),id=!0)},o(o){j(i.$$.fragment,o),j(R.$$.fragment,o),j(V.$$.fragment,o),j(Cn.$$.fragment,o),j(En.$$.fragment,o),j($n.$$.fragment,o),j(An.$$.fragment,o),j(Vn.$$.fragment,o),j(Dn.$$.fragment,o),j(Xn.$$.fragment,o),j(vo.$$.fragment,o),j(Pn.$$.fragment,o),j(Hn.$$.fragment,o),j(Yn.$$.fragment,o),j(es.$$.fragment,o),j(ts.$$.fragment,o),j(Uo.$$.fragment,o),j(os.$$.fragment,o),j(ss.$$.fragment,o),j(as.$$.fragment,o),j(is.$$.fragment,o),j(cs.$$.fragment,o),j(Eo.$$.fragment,o),j(ps.$$.fragment,o),j(us.$$.fragment,o),j(ys.$$.fragment,o),j(Fo.$$.fragment,o),j(Io.$$.fragment,o),j(_s.$$.fragment,o),j(Ms.$$.fragment,o),j(ks.$$.fragment,o),j(xo.$$.fragment,o),j(No.$$.fragment,o),j(vs.$$.fragment,o),j(Ls.$$.fragment,o),j(Fs.$$.fragment,o),j(Ao.$$.fragment,o),j(Ro.$$.fragment,o),j(Is.$$.fragment,o),j(zs.$$.fragment,o),j(Vs.$$.fragment,o),j(Vo.$$.fragment,o),j(Wo.$$.fragment,o),j(Ws.$$.fragment,o),j(Qs.$$.fragment,o),j(Ps.$$.fragment,o),j(Bo.$$.fragment,o),j(Hs.$$.fragment,o),j(Os.$$.fragment,o),j(Do.$$.fragment,o),j(ta.$$.fragment,o),j(Xo.$$.fragment,o),j(So.$$.fragment,o),j(oa.$$.fragment,o),j(na.$$.fragment,o),j(Ho.$$.fragment,o),j(ia.$$.fragment,o),j(Oo.$$.fragment,o),j(Yo.$$.fragment,o),j(da.$$.fragment,o),j(ca.$$.fragment,o),j(en.$$.fragment,o),j(ma.$$.fragment,o),j(tn.$$.fragment,o),j(on.$$.fragment,o),j(fa.$$.fragment,o),j(ga.$$.fragment,o),j(sn.$$.fragment,o),j(ba.$$.fragment,o),j(an.$$.fragment,o),j(rn.$$.fragment,o),j(Ta.$$.fragment,o),j(wa.$$.fragment,o),j(dn.$$.fragment,o),j(Ua.$$.fragment,o),j(cn.$$.fragment,o),j(pn.$$.fragment,o),id=!1},d(o){t(d),o&&t(b),o&&t(f),U(i),o&&t(ye),o&&t(W),o&&t(_e),o&&t(G),U(R),o&&t(Me),o&&t(se),o&&t(be),o&&t(oe),o&&t(Te),o&&t(Q),o&&t(we),o&&t(A),o&&t(ke),o&&t(ee),o&&t(ve),o&&t(N),o&&t(Ae),U(V,o),o&&t(Re),o&&t(ge),o&&t(ki),U(Cn,o),o&&t(vi),o&&t(Qt),U(En),o&&t(Li),o&&t(za),o&&t(ji),U($n,o),o&&t(Ui),o&&t(yt),o&&t(Ji),U(An,o),o&&t(Ci),o&&t(To),o&&t(Ei),U(Vn,o),o&&t($i),o&&t(wo),o&&t(Fi),o&&t(Ra),o&&t(Ii),o&&t(Za),o&&t(zi),o&&t(Wa),o&&t(xi),o&&t(Qa),o&&t(Ni),o&&t(Bt),U(Dn),o&&t(qi),o&&t(ut),U(Xn),U(vo),o&&t(Ai),o&&t(Xt),U(Pn),o&&t(Ri),o&&t(Ze),U(Hn),U(Yn),U(es),U(ts),U(Uo),U(os),o&&t(Zi),o&&t(Pt),U(ss),o&&t(Vi),o&&t(nt),U(as),U(is),U(cs),U(Eo),o&&t(Wi),o&&t(Ot),U(ps),o&&t(Qi),o&&t(ht),U(us),U(ys),U(Fo),U(Io),o&&t(Bi),o&&t(Kt),U(_s),o&&t(Gi),o&&t(mt),U(Ms),U(ks),U(xo),U(No),o&&t(Di),o&&t(oo),U(vs),o&&t(Xi),o&&t(st),U(Ls),U(Fs),U(Ao),U(Ro),o&&t(Si),o&&t(so),U(Is),o&&t(Pi),o&&t(at),U(zs),U(Vs),U(Vo),U(Wo),o&&t(Hi),o&&t(lo),U(Ws),o&&t(Oi),o&&t(rt),U(Qs),U(Ps),U(Bo),o&&t(Yi),o&&t(io),U(Hs),o&&t(Ki),o&&t(Oe),U(Os),U(Do),U(ta),U(Xo),U(So),o&&t(ed),o&&t(po),U(oa),o&&t(td),o&&t(Ye),U(na),U(Ho),U(ia),U(Oo),U(Yo),o&&t(od),o&&t(ho),U(da),o&&t(nd),o&&t(Ke),U(ca),U(en),U(ma),U(tn),U(on),o&&t(sd),o&&t(fo),U(fa),o&&t(ad),o&&t(et),U(ga),U(sn),U(ba),U(an),U(rn),o&&t(rd),o&&t(yo),U(Ta),o&&t(ld),o&&t(tt),U(wa),U(dn),U(Ua),U(cn),U(pn)}}}const bb={local:"layoutlm",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.LayoutLMConfig",title:"LayoutLMConfig"},{local:"transformers.LayoutLMTokenizer",title:"LayoutLMTokenizer"},{local:"transformers.LayoutLMTokenizerFast",title:"LayoutLMTokenizerFast"},{local:"transformers.LayoutLMModel",title:"LayoutLMModel"},{local:"transformers.LayoutLMForMaskedLM",title:"LayoutLMForMaskedLM"},{local:"transformers.LayoutLMForSequenceClassification",title:"LayoutLMForSequenceClassification"},{local:"transformers.LayoutLMForTokenClassification",title:"LayoutLMForTokenClassification"},{local:"transformers.LayoutLMForQuestionAnswering",title:"LayoutLMForQuestionAnswering"},{local:"transformers.TFLayoutLMModel",title:"TFLayoutLMModel"},{local:"transformers.TFLayoutLMForMaskedLM",title:"TFLayoutLMForMaskedLM"},{local:"transformers.TFLayoutLMForSequenceClassification",title:"TFLayoutLMForSequenceClassification"},{local:"transformers.TFLayoutLMForTokenClassification",title:"TFLayoutLMForTokenClassification"},{local:"transformers.TFLayoutLMForQuestionAnswering",title:"TFLayoutLMForQuestionAnswering"}],title:"LayoutLM"};function Tb(F){return GM(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cb extends VM{constructor(d){super();WM(this,d,Tb,Mb,QM,{})}}export{Cb as default,bb as metadata};
