import{S as Ub,i as Wb,s as Hb,e as a,k as c,w as v,t as n,M as Kb,c as r,d as t,m as p,a as i,x as L,h as s,b as u,G as e,g as m,y as T,q as M,o as $,B as x,v as Bb,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 lt}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 Yg}from"../../chunks/PipelineTag-hf-doc-builder.js";function Qb(z){let d,k,f,g,b;return g=new lt({props:{code:`from transformers import LayoutLMConfig, LayoutLMModel

# Initializing a LayoutLM configuration
configuration = LayoutLMConfig()

# Initializing a model (with random weights) from the configuration
model = LayoutLMModel(configuration)

# Accessing the model configuration
configuration = model.config`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function Rb(z){let d,k,f,g,b;return g=new lt({props:{code:`0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
| first sequence    | second sequence |`,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"),k=n("sequence pair mask has the following format:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"sequence pair mask has the following format:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function Vb(z){let d,k,f,g,b;return g=new lt({props:{code:`0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
| first sequence    | second sequence |`,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"),k=n("sequence pair mask has the following format:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"sequence pair mask has the following format:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function Xb(z){let d,k,f,g,b;return{c(){d=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),b=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(l){d=r(l,"P",{});var h=i(d);k=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var q=i(f);g=s(q,"Module"),q.forEach(t),b=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(l,h){m(l,d,h),e(d,k),e(d,f),e(f,g),e(d,b)},d(l){l&&t(d)}}}function Yb(z){let d,k,f,g,b;return g=new lt({props:{code:`from transformers import AutoTokenizer, LayoutLMModel
import torch

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = LayoutLMModel.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "world"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="pt")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = torch.tensor([token_boxes])

outputs = model(
    input_ids=input_ids, bbox=bbox, attention_mask=attention_mask, token_type_ids=token_type_ids
)

last_hidden_states = outputs.last_hidden_state`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function Zb(z){let d,k,f,g,b;return{c(){d=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),b=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(l){d=r(l,"P",{});var h=i(d);k=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var q=i(f);g=s(q,"Module"),q.forEach(t),b=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(l,h){m(l,d,h),e(d,k),e(d,f),e(f,g),e(d,b)},d(l){l&&t(d)}}}function Gb(z){let d,k,f,g,b;return g=new lt({props:{code:`from transformers import AutoTokenizer, LayoutLMForMaskedLM
import torch

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = LayoutLMForMaskedLM.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "[MASK]"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="pt")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = torch.tensor([token_boxes])

labels = tokenizer("Hello world", return_tensors="pt")["input_ids"]

outputs = model(
    input_ids=input_ids,
    bbox=bbox,
    attention_mask=attention_mask,
    token_type_ids=token_type_ids,
    labels=labels,
)

loss = outputs.loss`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function Jb(z){let d,k,f,g,b;return{c(){d=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),b=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(l){d=r(l,"P",{});var h=i(d);k=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var q=i(f);g=s(q,"Module"),q.forEach(t),b=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(l,h){m(l,d,h),e(d,k),e(d,f),e(f,g),e(d,b)},d(l){l&&t(d)}}}function ek(z){let d,k,f,g,b;return g=new lt({props:{code:`from transformers import AutoTokenizer, LayoutLMForSequenceClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = LayoutLMForSequenceClassification.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "world"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="pt")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = torch.tensor([token_boxes])
sequence_label = torch.tensor([1])

outputs = model(
    input_ids=input_ids,
    bbox=bbox,
    attention_mask=attention_mask,
    token_type_ids=token_type_ids,
    labels=sequence_label,
)

loss = outputs.loss
logits = outputs.logits`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function tk(z){let d,k,f,g,b;return{c(){d=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),b=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(l){d=r(l,"P",{});var h=i(d);k=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var q=i(f);g=s(q,"Module"),q.forEach(t),b=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(l,h){m(l,d,h),e(d,k),e(d,f),e(f,g),e(d,b)},d(l){l&&t(d)}}}function ok(z){let d,k,f,g,b;return g=new lt({props:{code:`from transformers import AutoTokenizer, LayoutLMForTokenClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = LayoutLMForTokenClassification.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "world"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="pt")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = torch.tensor([token_boxes])
token_labels = torch.tensor([1, 1, 0, 0]).unsqueeze(0)  # batch size of 1

outputs = model(
    input_ids=input_ids,
    bbox=bbox,
    attention_mask=attention_mask,
    token_type_ids=token_type_ids,
    labels=token_labels,
)

loss = outputs.loss
logits = outputs.logits`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function nk(z){let d,k;return d=new lt({props:{code:`from transformers import AutoTokenizer, LayoutLMForQuestionAnswering
from datasets import load_dataset
import torch

tokenizer = AutoTokenizer.from_pretrained("impira/layoutlm-document-qa", add_prefix_space=True)
model = LayoutLMForQuestionAnswering.from_pretrained("impira/layoutlm-document-qa", revision="1e3ebac")

dataset = load_dataset("nielsr/funsd", split="train")
example = dataset[0]
question = "what's his name?"
words = example["words"]
boxes = example["bboxes"]

encoding = tokenizer(
    question.split(), words, is_split_into_words=True, return_token_type_ids=True, return_tensors="pt"
)
bbox = []
for i, s, w in zip(encoding.input_ids[0], encoding.sequence_ids(0), encoding.word_ids(0)):
    if s == 1:
        bbox.append(boxes[w])
    elif i == tokenizer.sep_token_id:
        bbox.append([1000] * 4)
    else:
        bbox.append([0] * 4)
encoding["bbox"] = torch.tensor([bbox])

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = TFLayoutLMModel.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "world"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="tf")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = tf.convert_to_tensor([token_boxes])

outputs = model(
    input_ids=input_ids, bbox=bbox, attention_mask=attention_mask, token_type_ids=token_type_ids
)

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = TFLayoutLMForMaskedLM.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "[MASK]"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="tf")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = tf.convert_to_tensor([token_boxes])

labels = tokenizer("Hello world", return_tensors="tf")["input_ids"]

outputs = model(
    input_ids=input_ids,
    bbox=bbox,
    attention_mask=attention_mask,
    token_type_ids=token_type_ids,
    labels=labels,
)

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = TFLayoutLMForSequenceClassification.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "world"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="tf")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = tf.convert_to_tensor([token_boxes])
sequence_label = tf.convert_to_tensor([1])

outputs = model(
    input_ids=input_ids,
    bbox=bbox,
    attention_mask=attention_mask,
    token_type_ids=token_type_ids,
    labels=sequence_label,
)

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlm-base-uncased")
model = TFLayoutLMForTokenClassification.from_pretrained("microsoft/layoutlm-base-uncased")

words = ["Hello", "world"]
normalized_word_boxes = [637, 773, 693, 782], [698, 773, 733, 782]

token_boxes = []
for word, box in zip(words, normalized_word_boxes):
    word_tokens = tokenizer.tokenize(word)
    token_boxes.extend([box] * len(word_tokens))
# add bounding boxes of cls + sep tokens
token_boxes = [[0, 0, 0, 0]] + token_boxes + [[1000, 1000, 1000, 1000]]

encoding = tokenizer(" ".join(words), return_tensors="tf")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
token_type_ids = encoding["token_type_ids"]
bbox = tf.convert_to_tensor([token_boxes])
token_labels = tf.convert_to_tensor([1, 1, 0, 0])

outputs = model(
    input_ids=input_ids,
    bbox=bbox,
    attention_mask=attention_mask,
    token_type_ids=token_type_ids,
    labels=token_labels,
)

loss = outputs.loss
logits = outputs.logits`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function gk(z){let d,k,f,g,b,l,h,q,Me,_e,W,ye,B,w,he,I,$e,me,Q,be,se,R,ie,xe,V,ke,oe,S,je,le,ae,E,C,de,X,ce,Fe,Y,qe,pe,A,ue,Z,Ee,we,H,ze,ve,O,fe,G,Le,ee,P,Te,D,K,Ce;return{c(){d=a("p"),k=n("TensorFlow models and layers in "),f=a("code"),g=n("transformers"),b=n(" accept two formats as input:"),l=c(),h=a("ul"),q=a("li"),Me=n("having all inputs as keyword arguments (like PyTorch models), or"),_e=c(),W=a("li"),ye=n("having all inputs as a list, tuple or dict in the first positional argument."),B=c(),w=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 `),I=a("code"),$e=n("model.fit()"),me=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=a("code"),be=n("model.fit()"),se=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),R=a("code"),ie=n("fit()"),xe=n(" and "),V=a("code"),ke=n("predict()"),oe=n(`, such as when creating your own layers or models with
the Keras `),S=a("code"),je=n("Functional"),le=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),ae=c(),E=a("ul"),C=a("li"),de=n("a single Tensor with "),X=a("code"),ce=n("input_ids"),Fe=n(" only and nothing else: "),Y=a("code"),qe=n("model(input_ids)"),pe=c(),A=a("li"),ue=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Z=a("code"),Ee=n("model([input_ids, attention_mask])"),we=n(" or "),H=a("code"),ze=n("model([input_ids, attention_mask, token_type_ids])"),ve=c(),O=a("li"),fe=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),G=a("code"),Le=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ee=c(),P=a("p"),Te=n(`Note that when creating models and layers with
`),D=a("a"),K=n("subclassing"),Ce=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(y){d=r(y,"P",{});var j=i(d);k=s(j,"TensorFlow models and layers in "),f=r(j,"CODE",{});var Ue=i(f);g=s(Ue,"transformers"),Ue.forEach(t),b=s(j," accept two formats as input:"),j.forEach(t),l=p(y),h=r(y,"UL",{});var te=i(h);q=r(te,"LI",{});var We=i(q);Me=s(We,"having all inputs as keyword arguments (like PyTorch models), or"),We.forEach(t),_e=p(te),W=r(te,"LI",{});var He=i(W);ye=s(He,"having all inputs as a list, tuple or dict in the first positional argument."),He.forEach(t),te.forEach(t),B=p(y),w=r(y,"P",{});var F=i(w);he=s(F,`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 `),I=r(F,"CODE",{});var Ke=i(I);$e=s(Ke,"model.fit()"),Ke.forEach(t),me=s(F,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=r(F,"CODE",{});var Be=i(Q);be=s(Be,"model.fit()"),Be.forEach(t),se=s(F,` supports! If, however, you want to use the second
format outside of Keras methods like `),R=r(F,"CODE",{});var Pe=i(R);ie=s(Pe,"fit()"),Pe.forEach(t),xe=s(F," and "),V=r(F,"CODE",{});var Qe=i(V);ke=s(Qe,"predict()"),Qe.forEach(t),oe=s(F,`, such as when creating your own layers or models with
the Keras `),S=r(F,"CODE",{});var Re=i(S);je=s(Re,"Functional"),Re.forEach(t),le=s(F,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),F.forEach(t),ae=p(y),E=r(y,"UL",{});var N=i(E);C=r(N,"LI",{});var J=i(C);de=s(J,"a single Tensor with "),X=r(J,"CODE",{});var Ve=i(X);ce=s(Ve,"input_ids"),Ve.forEach(t),Fe=s(J," only and nothing else: "),Y=r(J,"CODE",{});var Oe=i(Y);qe=s(Oe,"model(input_ids)"),Oe.forEach(t),J.forEach(t),pe=p(N),A=r(N,"LI",{});var U=i(A);ue=s(U,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Z=r(U,"CODE",{});var Ie=i(Z);Ee=s(Ie,"model([input_ids, attention_mask])"),Ie.forEach(t),we=s(U," or "),H=r(U,"CODE",{});var ge=i(H);ze=s(ge,"model([input_ids, attention_mask, token_type_ids])"),ge.forEach(t),U.forEach(t),ve=p(N),O=r(N,"LI",{});var Ae=i(O);fe=s(Ae,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),G=r(Ae,"CODE",{});var Ne=i(G);Le=s(Ne,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),Ne.forEach(t),Ae.forEach(t),N.forEach(t),ee=p(y),P=r(y,"P",{});var re=i(P);Te=s(re,`Note that when creating models and layers with
`),D=r(re,"A",{href:!0,rel:!0});var Xe=i(D);K=s(Xe,"subclassing"),Xe.forEach(t),Ce=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(D,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(D,"rel","nofollow")},m(y,j){m(y,d,j),e(d,k),e(d,f),e(f,g),e(d,b),m(y,l,j),m(y,h,j),e(h,q),e(q,Me),e(h,_e),e(h,W),e(W,ye),m(y,B,j),m(y,w,j),e(w,he),e(w,I),e(I,$e),e(w,me),e(w,Q),e(Q,be),e(w,se),e(w,R),e(R,ie),e(w,xe),e(w,V),e(V,ke),e(w,oe),e(w,S),e(S,je),e(w,le),m(y,ae,j),m(y,E,j),e(E,C),e(C,de),e(C,X),e(X,ce),e(C,Fe),e(C,Y),e(Y,qe),e(E,pe),e(E,A),e(A,ue),e(A,Z),e(Z,Ee),e(A,we),e(A,H),e(H,ze),e(E,ve),e(E,O),e(O,fe),e(O,G),e(G,Le),m(y,ee,j),m(y,P,j),e(P,Te),e(P,D),e(D,K),e(P,Ce)},d(y){y&&t(d),y&&t(l),y&&t(h),y&&t(B),y&&t(w),y&&t(ae),y&&t(E),y&&t(ee),y&&t(P)}}}function _k(z){let d,k,f,g,b;return{c(){d=a("p"),k=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),g=n("Module"),b=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(l){d=r(l,"P",{});var h=i(d);k=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var q=i(f);g=s(q,"Module"),q.forEach(t),b=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(l,h){m(l,d,h),e(d,k),e(d,f),e(f,g),e(d,b)},d(l){l&&t(d)}}}function yk(z){let d,k,f,g,b;return g=new lt({props:{code:`import tensorflow as tf
from transformers import AutoTokenizer, TFLayoutLMForQuestionAnswering
from datasets import load_dataset

tokenizer = AutoTokenizer.from_pretrained("impira/layoutlm-document-qa", add_prefix_space=True)
model = TFLayoutLMForQuestionAnswering.from_pretrained("impira/layoutlm-document-qa", revision="1e3ebac")

dataset = load_dataset("nielsr/funsd", split="train")
example = dataset[0]
question = "what's his name?"
words = example["words"]
boxes = example["bboxes"]

encoding = tokenizer(
    question.split(), words, is_split_into_words=True, return_token_type_ids=True, return_tensors="tf"
)
bbox = []
for i, s, w in zip(encoding.input_ids[0], encoding.sequence_ids(0), encoding.word_ids(0)):
    if s == 1:
        bbox.append(boxes[w])
    elif i == tokenizer.sep_token_id:
        bbox.append([1000] * 4)
    else:
        bbox.append([0] * 4)
encoding["bbox"] = tf.convert_to_tensor([bbox])

word_ids = encoding.word_ids(0)
outputs = model(**encoding)
loss = outputs.loss
start_scores = outputs.start_logits
end_scores = outputs.end_logits
start, end = word_ids[tf.math.argmax(start_scores, -1)[0]], word_ids[tf.math.argmax(end_scores, -1)[0]]
print(" ".join(words[start : end + 1]))`,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"),k=n("Examples:"),f=c(),v(g.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);k=s(h,"Examples:"),h.forEach(t),f=p(l),L(g.$$.fragment,l)},m(l,h){m(l,d,h),e(d,k),m(l,f,h),T(g,l,h),b=!0},p:gt,i(l){b||(M(g.$$.fragment,l),b=!0)},o(l){$(g.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(f),x(g,l)}}}function bk(z){let d,k,f,g,b,l,h,q,Me,_e,W,ye,B,w,he,I,$e,me,Q,be,se,R,ie,xe,V,ke,oe,S,je,le,ae,E,C,de,X,ce,Fe,Y,qe,pe,A,ue,Z,Ee,we,H,ze,ve,O,fe,G,Le,ee,P,Te,D,K,Ce,y,j,Ue,te,We,He,F,Ke,Be,Pe,Qe,Re,N,J,Ve,Oe,U,Ie,ge,Ae,Ne,re,Xe,Er,rc,ic,Ll,Fn,Tl,Ht,ko,zr,qn,lc,Cr,dc,Ml,Aa,cc,$l,En,xl,_t,Ar,zn,pc,Cn,uc,hc,mc,Pr,An,fc,Pn,gc,_c,yc,Dr,Dn,bc,Nn,kc,wc,vc,Nr,Pa,Lc,Da,Tc,jl,On,Fl,wo,In,Mc,Sn,$c,xc,jc,Or,Na,Fc,ql,Un,El,vo,Wn,qc,Hn,Ec,zc,Cc,Ir,Oa,Ac,zl,Ia,Sr,Pc,Cl,Sa,Ur,Ua,Dc,Al,Wa,Nc,Pl,Ha,Kn,Oc,Bn,Ic,Sc,Dl,Kt,Lo,Wr,Qn,Uc,Hr,Wc,Nl,ut,Rn,Hc,Bt,Kc,Ka,Bc,Qc,Vn,Rc,Vc,Xc,Qt,Yc,Ba,Zc,Gc,Qa,Jc,ep,tp,To,Ol,Rt,Mo,Kr,Xn,op,Br,np,Il,Se,Yn,sp,Qr,ap,rp,Zn,ip,Ra,lp,dp,cp,Dt,Gn,pp,Rr,up,hp,Jn,Va,mp,Vr,fp,gp,Xa,_p,Xr,yp,bp,$o,es,kp,Yr,wp,vp,yt,ts,Lp,Zr,Tp,Mp,xo,$p,Vt,xp,Gr,jp,Fp,Jr,qp,Ep,zp,jo,os,Cp,ns,Ap,ei,Pp,Dp,Sl,Xt,Fo,ti,ss,Np,oi,Op,Ul,nt,as,Ip,rs,Sp,ni,Up,Wp,Hp,is,Kp,Ya,Bp,Qp,Rp,Nt,ls,Vp,si,Xp,Yp,ds,Za,Zp,ai,Gp,Jp,Ga,eu,ri,tu,ou,bt,cs,nu,ii,su,au,qo,ru,Yt,iu,li,lu,du,di,cu,pu,Wl,Zt,Eo,ci,ps,uu,pi,hu,Hl,ht,us,mu,hs,fu,ms,gu,_u,yu,fs,bu,gs,ku,wu,vu,kt,_s,Lu,Gt,Tu,Ja,Mu,$u,ui,xu,ju,Fu,zo,qu,Co,Kl,Jt,Ao,hi,ys,Eu,mi,zu,Bl,mt,bs,Cu,eo,Au,fi,Pu,Du,ks,Nu,Ou,Iu,ws,Su,vs,Uu,Wu,Hu,wt,Ls,Ku,to,Bu,er,Qu,Ru,gi,Vu,Xu,Yu,Po,Zu,Do,Ql,oo,No,_i,Ts,Gu,yi,Ju,Rl,st,Ms,eh,$s,th,xs,oh,nh,sh,js,ah,Fs,rh,ih,lh,qs,dh,Es,ch,ph,uh,vt,zs,hh,no,mh,tr,fh,gh,bi,_h,yh,bh,Oo,kh,Io,Vl,so,So,ki,Cs,wh,wi,vh,Xl,at,As,Lh,ao,Th,Ps,Mh,$h,Ds,xh,jh,Fh,Ns,qh,Os,Eh,zh,Ch,Is,Ah,Ss,Ph,Dh,Nh,Lt,Us,Oh,ro,Ih,or,Sh,Uh,vi,Wh,Hh,Kh,Uo,Bh,Wo,Yl,io,Ho,Li,Ws,Qh,Ti,Rh,Zl,rt,Hs,Vh,At,Xh,Ks,Yh,Zh,Mi,Gh,Jh,$i,em,tm,om,Bs,nm,Qs,sm,am,rm,Rs,im,Vs,lm,dm,cm,dt,Xs,pm,De,um,xi,hm,mm,ji,fm,gm,Fi,_m,ym,qi,bm,km,Ei,wm,vm,zi,Lm,Tm,Ci,Mm,$m,Ai,xm,jm,Fm,Pi,qm,Em,Di,zm,Cm,Ko,Gl,lo,Bo,Ni,Ys,Am,Oi,Pm,Jl,Ze,Zs,Dm,Ii,Nm,Om,Gs,Im,nr,Sm,Um,Wm,Js,Hm,ea,Km,Bm,Qm,Qo,Rm,Tt,ta,Vm,co,Xm,sr,Ym,Zm,Si,Gm,Jm,ef,Ro,tf,Vo,ed,po,Xo,Ui,oa,of,Wi,nf,td,Ge,na,sf,sa,af,Hi,rf,lf,df,aa,cf,ar,pf,uf,hf,ra,mf,ia,ff,gf,_f,Yo,yf,Mt,la,bf,uo,kf,rr,wf,vf,Ki,Lf,Tf,Mf,Zo,$f,Go,od,ho,Jo,Bi,da,xf,Qi,jf,nd,Je,ca,Ff,Ri,qf,Ef,pa,zf,ir,Cf,Af,Pf,ua,Df,ha,Nf,Of,If,en,Sf,$t,ma,Uf,mo,Wf,lr,Hf,Kf,Vi,Bf,Qf,Rf,tn,Vf,on,sd,fo,nn,Xi,fa,Xf,Yi,Yf,ad,et,ga,Zf,Zi,Gf,Jf,_a,eg,dr,tg,og,ng,ya,sg,ba,ag,rg,ig,sn,lg,xt,ka,dg,go,cg,cr,pg,ug,Gi,hg,mg,fg,an,gg,rn,rd,_o,ln,Ji,wa,_g,el,yg,id,tt,va,bg,Pt,kg,La,wg,vg,tl,Lg,Tg,ol,Mg,$g,xg,Ta,jg,pr,Fg,qg,Eg,Ma,zg,$a,Cg,Ag,Pg,dn,Dg,jt,xa,Ng,yo,Og,ur,Ig,Sg,nl,Ug,Wg,Hg,cn,Kg,pn,ld;return l=new ot({}),I=new ot({}),U=new lt({props:{code:`def normalize_bbox(bbox, width, height):
    return [
        int(1000 * (bbox[0] / width)),
        int(1000 * (bbox[1] / height)),
        int(1000 * (bbox[2] / width)),
        int(1000 * (bbox[3] / height)),
    ]`,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)),
    ]`}}),Fn=new lt({props:{code:`from PIL import Image

# Document can be a png, jpg, etc. PDFs must be converted to images.
image = Image.open(name_of_your_document).convert("RGB")

width, height = image.size`,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`}}),qn=new ot({}),En=new Yg({props:{pipeline:"document-question-answering"}}),On=new Yg({props:{pipeline:"text-classification"}}),Un=new Yg({props:{pipeline:"token-classification"}}),Qn=new ot({}),Rn=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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/configuration_layoutlm.py#L36"}}),To=new ft({props:{anchor:"transformers.LayoutLMConfig.example",$$slots:{default:[Qb]},$$scope:{ctx:z}}}),Xn=new ot({}),Yn=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/v4.29.0/src/transformers/models/layoutlm/tokenization_layoutlm.py#L75"}}),Gn=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/v4.29.0/src/transformers/models/layoutlm/tokenization_layoutlm.py#L205",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/v4.29.0/src/transformers/models/layoutlm/tokenization_layoutlm.py#L200"}}),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/v4.29.0/src/transformers/models/layoutlm/tokenization_layoutlm.py#L258",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>
`}}),xo=new ft({props:{anchor:"transformers.LayoutLMTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[Rb]},$$scope:{ctx:z}}}),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/v4.29.0/src/transformers/models/layoutlm/tokenization_layoutlm.py#L230",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/v4.29.0/src/transformers/models/layoutlm/tokenization_layoutlm_fast.py#L62"}}),ls=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/v4.29.0/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/v4.29.0/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>
`}}),qo=new ft({props:{anchor:"transformers.LayoutLMTokenizerFast.create_token_type_ids_from_sequences.example",$$slots:{default:[Vb]},$$scope:{ctx:z}}}),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/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L711"}}),_s=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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L737",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),zo=new pt({props:{$$slots:{default:[Xb]},$$scope:{ctx:z}}}),Co=new ft({props:{anchor:"transformers.LayoutLMModel.forward.example",$$slots:{default:[Yb]},$$scope:{ctx:z}}}),ys=new ot({}),bs=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/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L859"}}),Ls=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:" = None"},{name:"encoder_attention_mask",val:" = 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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L884",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Po=new pt({props:{$$slots:{default:[Zb]},$$scope:{ctx:z}}}),Do=new ft({props:{anchor:"transformers.LayoutLMForMaskedLM.forward.example",$$slots:{default:[Gb]},$$scope:{ctx:z}}}),Ts=new ot({}),Ms=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/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L994"}}),zs=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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L1008",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Oo=new pt({props:{$$slots:{default:[Jb]},$$scope:{ctx:z}}}),Io=new ft({props:{anchor:"transformers.LayoutLMForSequenceClassification.forward.example",$$slots:{default:[ek]},$$scope:{ctx:z}}}),Cs=new ot({}),As=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/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L1131"}}),Us=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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L1145",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Uo=new pt({props:{$$slots:{default:[tk]},$$scope:{ctx:z}}}),Wo=new ft({props:{anchor:"transformers.LayoutLMForTokenClassification.forward.example",$$slots:{default:[ok]},$$scope:{ctx:z}}}),Ws=new ot({}),Hs=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/v4.29.0/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/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L1249"}}),Xs=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/v4.29.0/src/transformers/models/layoutlm/modeling_layoutlm.py#L1263",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ko=new ft({props:{anchor:"transformers.LayoutLMForQuestionAnswering.forward.example",$$slots:{default:[nk]},$$scope:{ctx:z}}}),Ys=new ot({}),Zs=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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L918"}}),Qo=new pt({props:{$$slots:{default:[sk]},$$scope:{ctx:z}}}),ta=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMModel.call",parameters:[{name:"input_ids",val:": typing.Union[typing.List[tensorflow.python.framework.ops.Tensor], typing.List[numpy.ndarray], typing.List[keras.engine.keras_tensor.KerasTensor], typing.Dict[str, tensorflow.python.framework.ops.Tensor], typing.Dict[str, numpy.ndarray], typing.Dict[str, keras.engine.keras_tensor.KerasTensor], tensorflow.python.framework.ops.Tensor, numpy.ndarray, keras.engine.keras_tensor.KerasTensor, NoneType] = None"},{name:"bbox",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"attention_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"token_type_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"position_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"head_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"inputs_embeds",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"encoder_hidden_states",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"encoder_attention_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"training",val:": typing.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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L924",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Ro=new pt({props:{$$slots:{default:[ak]},$$scope:{ctx:z}}}),Vo=new ft({props:{anchor:"transformers.TFLayoutLMModel.call.example",$$slots:{default:[rk]},$$scope:{ctx:z}}}),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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1018"}}),Yo=new pt({props:{$$slots:{default:[ik]},$$scope:{ctx:z}}}),la=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForMaskedLM.call",parameters:[{name:"input_ids",val:": typing.Union[typing.List[tensorflow.python.framework.ops.Tensor], typing.List[numpy.ndarray], typing.List[keras.engine.keras_tensor.KerasTensor], typing.Dict[str, tensorflow.python.framework.ops.Tensor], typing.Dict[str, numpy.ndarray], typing.Dict[str, keras.engine.keras_tensor.KerasTensor], tensorflow.python.framework.ops.Tensor, numpy.ndarray, keras.engine.keras_tensor.KerasTensor, NoneType] = None"},{name:"bbox",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"attention_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"token_type_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"position_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"head_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"inputs_embeds",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"training",val:": typing.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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1046",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/en/main_classes/output#transformers.modeling_tf_outputs.TFMaskedLMOutput"
>transformers.modeling_tf_outputs.TFMaskedLMOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Zo=new pt({props:{$$slots:{default:[lk]},$$scope:{ctx:z}}}),Go=new ft({props:{anchor:"transformers.TFLayoutLMForMaskedLM.call.example",$$slots:{default:[dk]},$$scope:{ctx:z}}}),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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1151"}}),en=new pt({props:{$$slots:{default:[ck]},$$scope:{ctx:z}}}),ma=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForSequenceClassification.call",parameters:[{name:"input_ids",val:": typing.Union[typing.List[tensorflow.python.framework.ops.Tensor], typing.List[numpy.ndarray], typing.List[keras.engine.keras_tensor.KerasTensor], typing.Dict[str, tensorflow.python.framework.ops.Tensor], typing.Dict[str, numpy.ndarray], typing.Dict[str, keras.engine.keras_tensor.KerasTensor], tensorflow.python.framework.ops.Tensor, numpy.ndarray, keras.engine.keras_tensor.KerasTensor, NoneType] = None"},{name:"bbox",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"attention_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"token_type_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"position_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"head_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"inputs_embeds",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"training",val:": typing.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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1169",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/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:[pk]},$$scope:{ctx:z}}}),on=new ft({props:{anchor:"transformers.TFLayoutLMForSequenceClassification.call.example",$$slots:{default:[uk]},$$scope:{ctx:z}}}),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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1275"}}),sn=new pt({props:{$$slots:{default:[hk]},$$scope:{ctx:z}}}),ka=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForTokenClassification.call",parameters:[{name:"input_ids",val:": typing.Union[typing.List[tensorflow.python.framework.ops.Tensor], typing.List[numpy.ndarray], typing.List[keras.engine.keras_tensor.KerasTensor], typing.Dict[str, tensorflow.python.framework.ops.Tensor], typing.Dict[str, numpy.ndarray], typing.Dict[str, keras.engine.keras_tensor.KerasTensor], tensorflow.python.framework.ops.Tensor, numpy.ndarray, keras.engine.keras_tensor.KerasTensor, NoneType] = None"},{name:"bbox",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"attention_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"token_type_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"position_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"head_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"inputs_embeds",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"training",val:": typing.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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1299",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/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:[mk]},$$scope:{ctx:z}}}),rn=new ft({props:{anchor:"transformers.TFLayoutLMForTokenClassification.call.example",$$slots:{default:[fk]},$$scope:{ctx:z}}}),wa=new ot({}),va=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/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1404"}}),dn=new pt({props:{$$slots:{default:[gk]},$$scope:{ctx:z}}}),xa=new ne({props:{name:"call",anchor:"transformers.TFLayoutLMForQuestionAnswering.call",parameters:[{name:"input_ids",val:": typing.Union[typing.List[tensorflow.python.framework.ops.Tensor], typing.List[numpy.ndarray], typing.List[keras.engine.keras_tensor.KerasTensor], typing.Dict[str, tensorflow.python.framework.ops.Tensor], typing.Dict[str, numpy.ndarray], typing.Dict[str, keras.engine.keras_tensor.KerasTensor], tensorflow.python.framework.ops.Tensor, numpy.ndarray, keras.engine.keras_tensor.KerasTensor, NoneType] = None"},{name:"bbox",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"attention_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"token_type_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"position_ids",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"head_mask",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"inputs_embeds",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"start_positions",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"end_positions",val:": typing.Union[numpy.ndarray, tensorflow.python.framework.ops.Tensor, NoneType] = None"},{name:"training",val:": typing.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/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/src/transformers/models/layoutlm/modeling_tf_layoutlm.py#L1425",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.29.0/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/v4.29.0/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/v4.29.0/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:[_k]},$$scope:{ctx:z}}}),pn=new ft({props:{anchor:"transformers.TFLayoutLMForQuestionAnswering.call.example",$$slots:{default:[yk]},$$scope:{ctx:z}}}),{c(){d=a("meta"),k=c(),f=a("h1"),g=a("a"),b=a("span"),v(l.$$.fragment),h=c(),q=a("span"),Me=n("LayoutLM"),_e=c(),W=a("a"),ye=c(),B=a("h2"),w=a("a"),he=a("span"),v(I.$$.fragment),$e=c(),me=a("span"),Q=n("Overview"),be=c(),se=a("p"),R=n("The LayoutLM model was proposed in the paper "),ie=a("a"),xe=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),V=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:`),ke=c(),oe=a("ul"),S=a("li"),je=n("form understanding: the "),le=a("a"),ae=n("FUNSD"),E=n(` dataset (a collection of 199 annotated
forms comprising more than 30,000 words).`),C=c(),de=a("li"),X=n("receipt understanding: the "),ce=a("a"),Fe=n("SROIE"),Y=n(` dataset (a collection of 626 receipts for
training and 347 receipts for testing).`),qe=c(),pe=a("li"),A=n("document image classification: the "),ue=a("a"),Z=n("RVL-CDIP"),Ee=n(` dataset (a collection of
400,000 images belonging to one of 16 classes).`),we=c(),H=a("p"),ze=n("The abstract from the paper is the following:"),ve=c(),O=a("p"),fe=a("em"),G=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).`),Le=c(),ee=a("p"),P=n("Tips:"),Te=c(),D=a("ul"),K=a("li"),Ce=n("In addition to "),y=a("em"),j=n("input_ids"),Ue=n(", "),te=a("a"),We=n("forward()"),He=n(" also expects the input "),F=a("code"),Ke=n("bbox"),Be=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 `),Pe=a("a"),Qe=n("Tesseract"),Re=n(" (there\u2019s a "),N=a("a"),J=n("Python wrapper"),Ve=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:`),Oe=c(),v(U.$$.fragment),Ie=c(),ge=a("p"),Ae=n("Here, "),Ne=a("code"),re=n("width"),Xe=n(" and "),Er=a("code"),rc=n("height"),ic=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:`),Ll=c(),v(Fn.$$.fragment),Tl=c(),Ht=a("h2"),ko=a("a"),zr=a("span"),v(qn.$$.fragment),lc=c(),Cr=a("span"),dc=n("Resources"),Ml=c(),Aa=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."),$l=c(),v(En.$$.fragment),xl=c(),_t=a("ul"),Ar=a("li"),zn=a("p"),pc=n("A blog post on "),Cn=a("a"),uc=n(`fine-tuning
LayoutLM for document-understanding using Keras & Hugging Face
Transformers`),hc=n("."),mc=c(),Pr=a("li"),An=a("p"),fc=n("A blog post on how to "),Pn=a("a"),gc=n("fine-tune LayoutLM for document-understanding using only Hugging Face Transformers"),_c=n("."),yc=c(),Dr=a("li"),Dn=a("p"),bc=n("A notebook on how to "),Nn=a("a"),kc=n("fine-tune LayoutLM on the FUNSD dataset with image embeddings"),wc=n("."),vc=c(),Nr=a("li"),Pa=a("p"),Lc=n("See also: "),Da=a("a"),Tc=n("Document question answering task guide"),jl=c(),v(On.$$.fragment),Fl=c(),wo=a("ul"),In=a("li"),Mc=n("A notebook on how to "),Sn=a("a"),$c=n("fine-tune LayoutLM for sequence classification on the RVL-CDIP dataset"),xc=n("."),jc=c(),Or=a("li"),Na=a("a"),Fc=n("Text classification task guide"),ql=c(),v(Un.$$.fragment),El=c(),vo=a("ul"),Wn=a("li"),qc=n("A notebook on how to "),Hn=a("a"),Ec=n("fine-tune LayoutLM for token classification on the FUNSD dataset"),zc=n("."),Cc=c(),Ir=a("li"),Oa=a("a"),Ac=n("Token classification task guide"),zl=c(),Ia=a("p"),Sr=a("strong"),Pc=n("Other resources"),Cl=c(),Sa=a("ul"),Ur=a("li"),Ua=a("a"),Dc=n("Masked language modeling task guide"),Al=c(),Wa=a("p"),Nc=n("\u{1F680} Deploy"),Pl=c(),Ha=a("ul"),Kn=a("li"),Oc=n("A blog post on how to "),Bn=a("a"),Ic=n("Deploy LayoutLM with Hugging Face Inference Endpoints"),Sc=n("."),Dl=c(),Kt=a("h2"),Lo=a("a"),Wr=a("span"),v(Qn.$$.fragment),Uc=c(),Hr=a("span"),Wc=n("LayoutLMConfig"),Nl=c(),ut=a("div"),v(Rn.$$.fragment),Hc=c(),Bt=a("p"),Kc=n("This is the configuration class to store the configuration of a "),Ka=a("a"),Bc=n("LayoutLMModel"),Qc=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
`),Vn=a("a"),Rc=n("microsoft/layoutlm-base-uncased"),Vc=n(" architecture."),Xc=c(),Qt=a("p"),Yc=n("Configuration objects inherit from "),Ba=a("a"),Zc=n("BertConfig"),Gc=n(` and can be used to control the model outputs. Read the
documentation from `),Qa=a("a"),Jc=n("BertConfig"),ep=n(" for more information."),tp=c(),v(To.$$.fragment),Ol=c(),Rt=a("h2"),Mo=a("a"),Kr=a("span"),v(Xn.$$.fragment),op=c(),Br=a("span"),np=n("LayoutLMTokenizer"),Il=c(),Se=a("div"),v(Yn.$$.fragment),sp=c(),Qr=a("p"),ap=n("Construct a LayoutLM tokenizer. Based on WordPiece."),rp=c(),Zn=a("p"),ip=n("This tokenizer inherits from "),Ra=a("a"),lp=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(),Dt=a("div"),v(Gn.$$.fragment),pp=c(),Rr=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(),Jn=a("ul"),Va=a("li"),mp=n("single sequence: "),Vr=a("code"),fp=n("[CLS] X [SEP]"),gp=c(),Xa=a("li"),_p=n("pair of sequences: "),Xr=a("code"),yp=n("[CLS] A [SEP] B [SEP]"),bp=c(),$o=a("div"),v(es.$$.fragment),kp=c(),Yr=a("p"),wp=n("Converts a sequence of tokens (string) in a single string."),vp=c(),yt=a("div"),v(ts.$$.fragment),Lp=c(),Zr=a("p"),Tp=n("Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),Mp=c(),v(xo.$$.fragment),$p=c(),Vt=a("p"),xp=n("If "),Gr=a("code"),jp=n("token_ids_1"),Fp=n(" is "),Jr=a("code"),qp=n("None"),Ep=n(", this method only returns the first portion of the mask (0s)."),zp=c(),jo=a("div"),v(os.$$.fragment),Cp=c(),ns=a("p"),Ap=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 `),ei=a("code"),Pp=n("prepare_for_model"),Dp=n(" method."),Sl=c(),Xt=a("h2"),Fo=a("a"),ti=a("span"),v(ss.$$.fragment),Np=c(),oi=a("span"),Op=n("LayoutLMTokenizerFast"),Ul=c(),nt=a("div"),v(as.$$.fragment),Ip=c(),rs=a("p"),Sp=n("Construct a \u201Cfast\u201D LayoutLM tokenizer (backed by HuggingFace\u2019s "),ni=a("em"),Up=n("tokenizers"),Wp=n(" library). Based on WordPiece."),Hp=c(),is=a("p"),Kp=n("This tokenizer inherits from "),Ya=a("a"),Bp=n("PreTrainedTokenizerFast"),Qp=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Rp=c(),Nt=a("div"),v(ls.$$.fragment),Vp=c(),si=a("p"),Xp=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:`),Yp=c(),ds=a("ul"),Za=a("li"),Zp=n("single sequence: "),ai=a("code"),Gp=n("[CLS] X [SEP]"),Jp=c(),Ga=a("li"),eu=n("pair of sequences: "),ri=a("code"),tu=n("[CLS] A [SEP] B [SEP]"),ou=c(),bt=a("div"),v(cs.$$.fragment),nu=c(),ii=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(),v(qo.$$.fragment),ru=c(),Yt=a("p"),iu=n("If "),li=a("code"),lu=n("token_ids_1"),du=n(" is "),di=a("code"),cu=n("None"),pu=n(", this method only returns the first portion of the mask (0s)."),Wl=c(),Zt=a("h2"),Eo=a("a"),ci=a("span"),v(ps.$$.fragment),uu=c(),pi=a("span"),hu=n("LayoutLMModel"),Hl=c(),ht=a("div"),v(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`),_u=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),yu=c(),fs=a("p"),bu=n("This model is a PyTorch "),gs=a("a"),ku=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.`),vu=c(),kt=a("div"),v(_s.$$.fragment),Lu=c(),Gt=a("p"),Tu=n("The "),Ja=a("a"),Mu=n("LayoutLMModel"),$u=n(" forward method, overrides the "),ui=a("code"),xu=n("__call__"),ju=n(" special method."),Fu=c(),v(zo.$$.fragment),qu=c(),v(Co.$$.fragment),Kl=c(),Jt=a("h2"),Ao=a("a"),hi=a("span"),v(ys.$$.fragment),Eu=c(),mi=a("span"),zu=n("LayoutLMForMaskedLM"),Bl=c(),mt=a("div"),v(bs.$$.fragment),Cu=c(),eo=a("p"),Au=n("LayoutLM Model with a "),fi=a("code"),Pu=n("language modeling"),Du=n(` head on top.
The LayoutLM model was proposed in `),ks=a("a"),Nu=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),Ou=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Iu=c(),ws=a("p"),Su=n("This model is a PyTorch "),vs=a("a"),Uu=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.`),Hu=c(),wt=a("div"),v(Ls.$$.fragment),Ku=c(),to=a("p"),Bu=n("The "),er=a("a"),Qu=n("LayoutLMForMaskedLM"),Ru=n(" forward method, overrides the "),gi=a("code"),Vu=n("__call__"),Xu=n(" special method."),Yu=c(),v(Po.$$.fragment),Zu=c(),v(Do.$$.fragment),Ql=c(),oo=a("h2"),No=a("a"),_i=a("span"),v(Ts.$$.fragment),Gu=c(),yi=a("span"),Ju=n("LayoutLMForSequenceClassification"),Rl=c(),st=a("div"),v(Ms.$$.fragment),eh=c(),$s=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 `),xs=a("a"),oh=n("RVL-CDIP"),nh=n(" dataset."),sh=c(),js=a("p"),ah=n("The LayoutLM model was proposed in "),Fs=a("a"),rh=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),ih=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),lh=c(),qs=a("p"),dh=n("This model is a PyTorch "),Es=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(),vt=a("div"),v(zs.$$.fragment),hh=c(),no=a("p"),mh=n("The "),tr=a("a"),fh=n("LayoutLMForSequenceClassification"),gh=n(" forward method, overrides the "),bi=a("code"),_h=n("__call__"),yh=n(" special method."),bh=c(),v(Oo.$$.fragment),kh=c(),v(Io.$$.fragment),Vl=c(),so=a("h2"),So=a("a"),ki=a("span"),v(Cs.$$.fragment),wh=c(),wi=a("span"),vh=n("LayoutLMForTokenClassification"),Xl=c(),at=a("div"),v(As.$$.fragment),Lh=c(),ao=a("p"),Th=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 `),Ps=a("a"),Mh=n("FUNSD"),$h=n(`
dataset and the `),Ds=a("a"),xh=n("SROIE"),jh=n(" dataset."),Fh=c(),Ns=a("p"),qh=n("The LayoutLM model was proposed in "),Os=a("a"),Eh=n(`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),zh=n(` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Ch=c(),Is=a("p"),Ah=n("This model is a PyTorch "),Ss=a("a"),Ph=n("torch.nn.Module"),Dh=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.`),Nh=c(),Lt=a("div"),v(Us.$$.fragment),Oh=c(),ro=a("p"),Ih=n("The "),or=a("a"),Sh=n("LayoutLMForTokenClassification"),Uh=n(" forward method, overrides the "),vi=a("code"),Wh=n("__call__"),Hh=n(" special method."),Kh=c(),v(Uo.$$.fragment),Bh=c(),v(Wo.$$.fragment),Yl=c(),io=a("h2"),Ho=a("a"),Li=a("span"),v(Ws.$$.fragment),Qh=c(),Ti=a("span"),Rh=n("LayoutLMForQuestionAnswering"),Zl=c(),rt=a("div"),v(Hs.$$.fragment),Vh=c(),At=a("p"),Xh=n(`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),Ks=a("a"),Yh=n("DocVQA"),Zh=n(" (a linear layer on top of the final hidden-states output to compute "),Mi=a("code"),Gh=n("span start logits"),Jh=n(" and "),$i=a("code"),em=n("span end logits"),tm=n(")."),om=c(),Bs=a("p"),nm=n("The LayoutLM model was proposed in "),Qs=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(),Rs=a("p"),im=n("This model is a PyTorch "),Vs=a("a"),lm=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"),v(Xs.$$.fragment),pm=c(),De=a("p"),um=n("start_positions ("),xi=a("code"),hm=n("torch.LongTensor"),mm=n(" of shape "),ji=a("code"),fm=n("(batch_size,)"),gm=n(", "),Fi=a("em"),_m=n("optional"),ym=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 (`),qi=a("code"),bm=n("sequence_length"),km=n(`). Position outside of the sequence
are not taken into account for computing the loss.
end_positions (`),Ei=a("code"),wm=n("torch.LongTensor"),vm=n(" of shape "),zi=a("code"),Lm=n("(batch_size,)"),Tm=n(", "),Ci=a("em"),Mm=n("optional"),$m=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 (`),Ai=a("code"),xm=n("sequence_length"),jm=n(`). Position outside of the sequence
are not taken into account for computing the loss.`),Fm=c(),Pi=a("p"),qm=n("Example:"),Em=c(),Di=a("p"),zm=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).`),Cm=c(),v(Ko.$$.fragment),Gl=c(),lo=a("h2"),Bo=a("a"),Ni=a("span"),v(Ys.$$.fragment),Am=c(),Oi=a("span"),Pm=n("TFLayoutLMModel"),Jl=c(),Ze=a("div"),v(Zs.$$.fragment),Dm=c(),Ii=a("p"),Nm=n("The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top."),Om=c(),Gs=a("p"),Im=n("This model inherits from "),nr=a("a"),Sm=n("TFPreTrainedModel"),Um=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(),Js=a("p"),Hm=n("This model is also a "),ea=a("a"),Km=n("tf.keras.Model"),Bm=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.`),Qm=c(),v(Qo.$$.fragment),Rm=c(),Tt=a("div"),v(ta.$$.fragment),Vm=c(),co=a("p"),Xm=n("The "),sr=a("a"),Ym=n("TFLayoutLMModel"),Zm=n(" forward method, overrides the "),Si=a("code"),Gm=n("__call__"),Jm=n(" special method."),ef=c(),v(Ro.$$.fragment),tf=c(),v(Vo.$$.fragment),ed=c(),po=a("h2"),Xo=a("a"),Ui=a("span"),v(oa.$$.fragment),of=c(),Wi=a("span"),nf=n("TFLayoutLMForMaskedLM"),td=c(),Ge=a("div"),v(na.$$.fragment),sf=c(),sa=a("p"),af=n("LayoutLM Model with a "),Hi=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 "),ia=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.`),_f=c(),v(Yo.$$.fragment),yf=c(),Mt=a("div"),v(la.$$.fragment),bf=c(),uo=a("p"),kf=n("The "),rr=a("a"),wf=n("TFLayoutLMForMaskedLM"),vf=n(" forward method, overrides the "),Ki=a("code"),Lf=n("__call__"),Tf=n(" special method."),Mf=c(),v(Zo.$$.fragment),$f=c(),v(Go.$$.fragment),od=c(),ho=a("h2"),Jo=a("a"),Bi=a("span"),v(da.$$.fragment),xf=c(),Qi=a("span"),jf=n("TFLayoutLMForSequenceClassification"),nd=c(),Je=a("div"),v(ca.$$.fragment),Ff=c(),Ri=a("p"),qf=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.`),Ef=c(),pa=a("p"),zf=n("This model inherits from "),ir=a("a"),Cf=n("TFPreTrainedModel"),Af=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.)`),Pf=c(),ua=a("p"),Df=n("This model is also a "),ha=a("a"),Nf=n("tf.keras.Model"),Of=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.`),If=c(),v(en.$$.fragment),Sf=c(),$t=a("div"),v(ma.$$.fragment),Uf=c(),mo=a("p"),Wf=n("The "),lr=a("a"),Hf=n("TFLayoutLMForSequenceClassification"),Kf=n(" forward method, overrides the "),Vi=a("code"),Bf=n("__call__"),Qf=n(" special method."),Rf=c(),v(tn.$$.fragment),Vf=c(),v(on.$$.fragment),sd=c(),fo=a("h2"),nn=a("a"),Xi=a("span"),v(fa.$$.fragment),Xf=c(),Yi=a("span"),Yf=n("TFLayoutLMForTokenClassification"),ad=c(),et=a("div"),v(ga.$$.fragment),Zf=c(),Zi=a("p"),Gf=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.`),Jf=c(),_a=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(),ya=a("p"),sg=n("This model is also a "),ba=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.`),ig=c(),v(sn.$$.fragment),lg=c(),xt=a("div"),v(ka.$$.fragment),dg=c(),go=a("p"),cg=n("The "),cr=a("a"),pg=n("TFLayoutLMForTokenClassification"),ug=n(" forward method, overrides the "),Gi=a("code"),hg=n("__call__"),mg=n(" special method."),fg=c(),v(an.$$.fragment),gg=c(),v(rn.$$.fragment),rd=c(),_o=a("h2"),ln=a("a"),Ji=a("span"),v(wa.$$.fragment),_g=c(),el=a("span"),yg=n("TFLayoutLMForQuestionAnswering"),id=c(),tt=a("div"),v(va.$$.fragment),bg=c(),Pt=a("p"),kg=n(`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),La=a("a"),wg=n("DocVQA"),vg=n(" (a linear layer on top of the final hidden-states output to compute "),tl=a("code"),Lg=n("span start logits"),Tg=n(" and "),ol=a("code"),Mg=n("span end logits"),$g=n(")."),xg=c(),Ta=a("p"),jg=n("This model inherits from "),pr=a("a"),Fg=n("TFPreTrainedModel"),qg=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.)`),Eg=c(),Ma=a("p"),zg=n("This model is also a "),$a=a("a"),Cg=n("tf.keras.Model"),Ag=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.`),Pg=c(),v(dn.$$.fragment),Dg=c(),jt=a("div"),v(xa.$$.fragment),Ng=c(),yo=a("p"),Og=n("The "),ur=a("a"),Ig=n("TFLayoutLMForQuestionAnswering"),Sg=n(" forward method, overrides the "),nl=a("code"),Ug=n("__call__"),Wg=n(" special method."),Hg=c(),v(cn.$$.fragment),Kg=c(),v(pn.$$.fragment),this.h()},l(o){const _=Kb('[data-svelte="svelte-1phssyn"]',document.head);d=r(_,"META",{name:!0,content:!0}),_.forEach(t),k=p(o),f=r(o,"H1",{class:!0});var ja=i(f);g=r(ja,"A",{id:!0,class:!0,href:!0});var sl=i(g);b=r(sl,"SPAN",{});var al=i(b);L(l.$$.fragment,al),al.forEach(t),sl.forEach(t),h=p(ja),q=r(ja,"SPAN",{});var rl=i(q);Me=s(rl,"LayoutLM"),rl.forEach(t),ja.forEach(t),_e=p(o),W=r(o,"A",{id:!0}),i(W).forEach(t),ye=p(o),B=r(o,"H2",{class:!0});var Fa=i(B);w=r(Fa,"A",{id:!0,class:!0,href:!0});var il=i(w);he=r(il,"SPAN",{});var ll=i(he);L(I.$$.fragment,ll),ll.forEach(t),il.forEach(t),$e=p(Fa),me=r(Fa,"SPAN",{});var dl=i(me);Q=s(dl,"Overview"),dl.forEach(t),Fa.forEach(t),be=p(o),se=r(o,"P",{});var qa=i(se);R=s(qa,"The LayoutLM model was proposed in the paper "),ie=r(qa,"A",{href:!0,rel:!0});var cl=i(ie);xe=s(cl,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),cl.forEach(t),V=s(qa,` 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:`),qa.forEach(t),ke=p(o),oe=r(o,"UL",{});var bo=i(oe);S=r(bo,"LI",{});var Ea=i(S);je=s(Ea,"form understanding: the "),le=r(Ea,"A",{href:!0,rel:!0});var pl=i(le);ae=s(pl,"FUNSD"),pl.forEach(t),E=s(Ea,` dataset (a collection of 199 annotated
forms comprising more than 30,000 words).`),Ea.forEach(t),C=p(bo),de=r(bo,"LI",{});var za=i(de);X=s(za,"receipt understanding: the "),ce=r(za,"A",{href:!0,rel:!0});var ul=i(ce);Fe=s(ul,"SROIE"),ul.forEach(t),Y=s(za,` dataset (a collection of 626 receipts for
training and 347 receipts for testing).`),za.forEach(t),qe=p(bo),pe=r(bo,"LI",{});var Ca=i(pe);A=s(Ca,"document image classification: the "),ue=r(Ca,"A",{href:!0,rel:!0});var hl=i(ue);Z=s(hl,"RVL-CDIP"),hl.forEach(t),Ee=s(Ca,` dataset (a collection of
400,000 images belonging to one of 16 classes).`),Ca.forEach(t),bo.forEach(t),we=p(o),H=r(o,"P",{});var ml=i(H);ze=s(ml,"The abstract from the paper is the following:"),ml.forEach(t),ve=p(o),O=r(o,"P",{});var fl=i(O);fe=r(fl,"EM",{});var gl=i(fe);G=s(gl,`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).`),gl.forEach(t),fl.forEach(t),Le=p(o),ee=r(o,"P",{});var _l=i(ee);P=s(_l,"Tips:"),_l.forEach(t),Te=p(o),D=r(o,"UL",{});var yl=i(D);K=r(yl,"LI",{});var it=i(K);Ce=s(it,"In addition to "),y=r(it,"EM",{});var bl=i(y);j=s(bl,"input_ids"),bl.forEach(t),Ue=s(it,", "),te=r(it,"A",{href:!0});var kl=i(te);We=s(kl,"forward()"),kl.forEach(t),He=s(it," also expects the input "),F=r(it,"CODE",{});var wl=i(F);Ke=s(wl,"bbox"),wl.forEach(t),Be=s(it,`, 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 `),Pe=r(it,"A",{href:!0,rel:!0});var vl=i(Pe);Qe=s(vl,"Tesseract"),vl.forEach(t),Re=s(it," (there\u2019s a "),N=r(it,"A",{href:!0,rel:!0});var Zg=i(N);J=s(Zg,"Python wrapper"),Zg.forEach(t),Ve=s(it,` 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:`),it.forEach(t),yl.forEach(t),Oe=p(o),L(U.$$.fragment,o),Ie=p(o),ge=r(o,"P",{});var hr=i(ge);Ae=s(hr,"Here, "),Ne=r(hr,"CODE",{});var Gg=i(Ne);re=s(Gg,"width"),Gg.forEach(t),Xe=s(hr," and "),Er=r(hr,"CODE",{});var Jg=i(Er);rc=s(Jg,"height"),Jg.forEach(t),ic=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),Ll=p(o),L(Fn.$$.fragment,o),Tl=p(o),Ht=r(o,"H2",{class:!0});var dd=i(Ht);ko=r(dd,"A",{id:!0,class:!0,href:!0});var e_=i(ko);zr=r(e_,"SPAN",{});var t_=i(zr);L(qn.$$.fragment,t_),t_.forEach(t),e_.forEach(t),lc=p(dd),Cr=r(dd,"SPAN",{});var o_=i(Cr);dc=s(o_,"Resources"),o_.forEach(t),dd.forEach(t),Ml=p(o),Aa=r(o,"P",{});var n_=i(Aa);cc=s(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."),n_.forEach(t),$l=p(o),L(En.$$.fragment,o),xl=p(o),_t=r(o,"UL",{});var un=i(_t);Ar=r(un,"LI",{});var s_=i(Ar);zn=r(s_,"P",{});var cd=i(zn);pc=s(cd,"A blog post on "),Cn=r(cd,"A",{href:!0,rel:!0});var a_=i(Cn);uc=s(a_,`fine-tuning
LayoutLM for document-understanding using Keras & Hugging Face
Transformers`),a_.forEach(t),hc=s(cd,"."),cd.forEach(t),s_.forEach(t),mc=p(un),Pr=r(un,"LI",{});var r_=i(Pr);An=r(r_,"P",{});var pd=i(An);fc=s(pd,"A blog post on how to "),Pn=r(pd,"A",{href:!0,rel:!0});var i_=i(Pn);gc=s(i_,"fine-tune LayoutLM for document-understanding using only Hugging Face Transformers"),i_.forEach(t),_c=s(pd,"."),pd.forEach(t),r_.forEach(t),yc=p(un),Dr=r(un,"LI",{});var l_=i(Dr);Dn=r(l_,"P",{});var ud=i(Dn);bc=s(ud,"A notebook on how to "),Nn=r(ud,"A",{href:!0,rel:!0});var d_=i(Nn);kc=s(d_,"fine-tune LayoutLM on the FUNSD dataset with image embeddings"),d_.forEach(t),wc=s(ud,"."),ud.forEach(t),l_.forEach(t),vc=p(un),Nr=r(un,"LI",{});var c_=i(Nr);Pa=r(c_,"P",{});var Bg=i(Pa);Lc=s(Bg,"See also: "),Da=r(Bg,"A",{href:!0});var p_=i(Da);Tc=s(p_,"Document question answering task guide"),p_.forEach(t),Bg.forEach(t),c_.forEach(t),un.forEach(t),jl=p(o),L(On.$$.fragment,o),Fl=p(o),wo=r(o,"UL",{});var hd=i(wo);In=r(hd,"LI",{});var md=i(In);Mc=s(md,"A notebook on how to "),Sn=r(md,"A",{href:!0,rel:!0});var u_=i(Sn);$c=s(u_,"fine-tune LayoutLM for sequence classification on the RVL-CDIP dataset"),u_.forEach(t),xc=s(md,"."),md.forEach(t),jc=p(hd),Or=r(hd,"LI",{});var h_=i(Or);Na=r(h_,"A",{href:!0});var m_=i(Na);Fc=s(m_,"Text classification task guide"),m_.forEach(t),h_.forEach(t),hd.forEach(t),ql=p(o),L(Un.$$.fragment,o),El=p(o),vo=r(o,"UL",{});var fd=i(vo);Wn=r(fd,"LI",{});var gd=i(Wn);qc=s(gd,"A notebook on how to "),Hn=r(gd,"A",{href:!0,rel:!0});var f_=i(Hn);Ec=s(f_,"fine-tune LayoutLM for token classification on the FUNSD dataset"),f_.forEach(t),zc=s(gd,"."),gd.forEach(t),Cc=p(fd),Ir=r(fd,"LI",{});var g_=i(Ir);Oa=r(g_,"A",{href:!0});var __=i(Oa);Ac=s(__,"Token classification task guide"),__.forEach(t),g_.forEach(t),fd.forEach(t),zl=p(o),Ia=r(o,"P",{});var y_=i(Ia);Sr=r(y_,"STRONG",{});var b_=i(Sr);Pc=s(b_,"Other resources"),b_.forEach(t),y_.forEach(t),Cl=p(o),Sa=r(o,"UL",{});var k_=i(Sa);Ur=r(k_,"LI",{});var w_=i(Ur);Ua=r(w_,"A",{href:!0});var v_=i(Ua);Dc=s(v_,"Masked language modeling task guide"),v_.forEach(t),w_.forEach(t),k_.forEach(t),Al=p(o),Wa=r(o,"P",{});var L_=i(Wa);Nc=s(L_,"\u{1F680} Deploy"),L_.forEach(t),Pl=p(o),Ha=r(o,"UL",{});var T_=i(Ha);Kn=r(T_,"LI",{});var _d=i(Kn);Oc=s(_d,"A blog post on how to "),Bn=r(_d,"A",{href:!0,rel:!0});var M_=i(Bn);Ic=s(M_,"Deploy LayoutLM with Hugging Face Inference Endpoints"),M_.forEach(t),Sc=s(_d,"."),_d.forEach(t),T_.forEach(t),Dl=p(o),Kt=r(o,"H2",{class:!0});var yd=i(Kt);Lo=r(yd,"A",{id:!0,class:!0,href:!0});var $_=i(Lo);Wr=r($_,"SPAN",{});var x_=i(Wr);L(Qn.$$.fragment,x_),x_.forEach(t),$_.forEach(t),Uc=p(yd),Hr=r(yd,"SPAN",{});var j_=i(Hr);Wc=s(j_,"LayoutLMConfig"),j_.forEach(t),yd.forEach(t),Nl=p(o),ut=r(o,"DIV",{class:!0});var hn=i(ut);L(Rn.$$.fragment,hn),Hc=p(hn),Bt=r(hn,"P",{});var mr=i(Bt);Kc=s(mr,"This is the configuration class to store the configuration of a "),Ka=r(mr,"A",{href:!0});var F_=i(Ka);Bc=s(F_,"LayoutLMModel"),F_.forEach(t),Qc=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
`),Vn=r(mr,"A",{href:!0,rel:!0});var q_=i(Vn);Rc=s(q_,"microsoft/layoutlm-base-uncased"),q_.forEach(t),Vc=s(mr," architecture."),mr.forEach(t),Xc=p(hn),Qt=r(hn,"P",{});var fr=i(Qt);Yc=s(fr,"Configuration objects inherit from "),Ba=r(fr,"A",{href:!0});var E_=i(Ba);Zc=s(E_,"BertConfig"),E_.forEach(t),Gc=s(fr,` and can be used to control the model outputs. Read the
documentation from `),Qa=r(fr,"A",{href:!0});var z_=i(Qa);Jc=s(z_,"BertConfig"),z_.forEach(t),ep=s(fr," for more information."),fr.forEach(t),tp=p(hn),L(To.$$.fragment,hn),hn.forEach(t),Ol=p(o),Rt=r(o,"H2",{class:!0});var bd=i(Rt);Mo=r(bd,"A",{id:!0,class:!0,href:!0});var C_=i(Mo);Kr=r(C_,"SPAN",{});var A_=i(Kr);L(Xn.$$.fragment,A_),A_.forEach(t),C_.forEach(t),op=p(bd),Br=r(bd,"SPAN",{});var P_=i(Br);np=s(P_,"LayoutLMTokenizer"),P_.forEach(t),bd.forEach(t),Il=p(o),Se=r(o,"DIV",{class:!0});var ct=i(Se);L(Yn.$$.fragment,ct),sp=p(ct),Qr=r(ct,"P",{});var D_=i(Qr);ap=s(D_,"Construct a LayoutLM tokenizer. Based on WordPiece."),D_.forEach(t),rp=p(ct),Zn=r(ct,"P",{});var kd=i(Zn);ip=s(kd,"This tokenizer inherits from "),Ra=r(kd,"A",{href:!0});var N_=i(Ra);lp=s(N_,"PreTrainedTokenizer"),N_.forEach(t),dp=s(kd,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),kd.forEach(t),cp=p(ct),Dt=r(ct,"DIV",{class:!0});var gr=i(Dt);L(Gn.$$.fragment,gr),pp=p(gr),Rr=r(gr,"P",{});var O_=i(Rr);up=s(O_,`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:`),O_.forEach(t),hp=p(gr),Jn=r(gr,"UL",{});var wd=i(Jn);Va=r(wd,"LI",{});var Qg=i(Va);mp=s(Qg,"single sequence: "),Vr=r(Qg,"CODE",{});var I_=i(Vr);fp=s(I_,"[CLS] X [SEP]"),I_.forEach(t),Qg.forEach(t),gp=p(wd),Xa=r(wd,"LI",{});var Rg=i(Xa);_p=s(Rg,"pair of sequences: "),Xr=r(Rg,"CODE",{});var S_=i(Xr);yp=s(S_,"[CLS] A [SEP] B [SEP]"),S_.forEach(t),Rg.forEach(t),wd.forEach(t),gr.forEach(t),bp=p(ct),$o=r(ct,"DIV",{class:!0});var vd=i($o);L(es.$$.fragment,vd),kp=p(vd),Yr=r(vd,"P",{});var U_=i(Yr);wp=s(U_,"Converts a sequence of tokens (string) in a single string."),U_.forEach(t),vd.forEach(t),vp=p(ct),yt=r(ct,"DIV",{class:!0});var mn=i(yt);L(ts.$$.fragment,mn),Lp=p(mn),Zr=r(mn,"P",{});var W_=i(Zr);Tp=s(W_,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),W_.forEach(t),Mp=p(mn),L(xo.$$.fragment,mn),$p=p(mn),Vt=r(mn,"P",{});var _r=i(Vt);xp=s(_r,"If "),Gr=r(_r,"CODE",{});var H_=i(Gr);jp=s(H_,"token_ids_1"),H_.forEach(t),Fp=s(_r," is "),Jr=r(_r,"CODE",{});var K_=i(Jr);qp=s(K_,"None"),K_.forEach(t),Ep=s(_r,", this method only returns the first portion of the mask (0s)."),_r.forEach(t),mn.forEach(t),zp=p(ct),jo=r(ct,"DIV",{class:!0});var Ld=i(jo);L(os.$$.fragment,Ld),Cp=p(Ld),ns=r(Ld,"P",{});var Td=i(ns);Ap=s(Td,`Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer `),ei=r(Td,"CODE",{});var B_=i(ei);Pp=s(B_,"prepare_for_model"),B_.forEach(t),Dp=s(Td," method."),Td.forEach(t),Ld.forEach(t),ct.forEach(t),Sl=p(o),Xt=r(o,"H2",{class:!0});var Md=i(Xt);Fo=r(Md,"A",{id:!0,class:!0,href:!0});var Q_=i(Fo);ti=r(Q_,"SPAN",{});var R_=i(ti);L(ss.$$.fragment,R_),R_.forEach(t),Q_.forEach(t),Np=p(Md),oi=r(Md,"SPAN",{});var V_=i(oi);Op=s(V_,"LayoutLMTokenizerFast"),V_.forEach(t),Md.forEach(t),Ul=p(o),nt=r(o,"DIV",{class:!0});var Ot=i(nt);L(as.$$.fragment,Ot),Ip=p(Ot),rs=r(Ot,"P",{});var $d=i(rs);Sp=s($d,"Construct a \u201Cfast\u201D LayoutLM tokenizer (backed by HuggingFace\u2019s "),ni=r($d,"EM",{});var X_=i(ni);Up=s(X_,"tokenizers"),X_.forEach(t),Wp=s($d," library). Based on WordPiece."),$d.forEach(t),Hp=p(Ot),is=r(Ot,"P",{});var xd=i(is);Kp=s(xd,"This tokenizer inherits from "),Ya=r(xd,"A",{href:!0});var Y_=i(Ya);Bp=s(Y_,"PreTrainedTokenizerFast"),Y_.forEach(t),Qp=s(xd,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),xd.forEach(t),Rp=p(Ot),Nt=r(Ot,"DIV",{class:!0});var yr=i(Nt);L(ls.$$.fragment,yr),Vp=p(yr),si=r(yr,"P",{});var Z_=i(si);Xp=s(Z_,`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:`),Z_.forEach(t),Yp=p(yr),ds=r(yr,"UL",{});var jd=i(ds);Za=r(jd,"LI",{});var Vg=i(Za);Zp=s(Vg,"single sequence: "),ai=r(Vg,"CODE",{});var G_=i(ai);Gp=s(G_,"[CLS] X [SEP]"),G_.forEach(t),Vg.forEach(t),Jp=p(jd),Ga=r(jd,"LI",{});var Xg=i(Ga);eu=s(Xg,"pair of sequences: "),ri=r(Xg,"CODE",{});var J_=i(ri);tu=s(J_,"[CLS] A [SEP] B [SEP]"),J_.forEach(t),Xg.forEach(t),jd.forEach(t),yr.forEach(t),ou=p(Ot),bt=r(Ot,"DIV",{class:!0});var fn=i(bt);L(cs.$$.fragment,fn),nu=p(fn),ii=r(fn,"P",{});var ey=i(ii);su=s(ey,"Create a mask from the two sequences passed to be used in a sequence-pair classification task. A LayoutLM"),ey.forEach(t),au=p(fn),L(qo.$$.fragment,fn),ru=p(fn),Yt=r(fn,"P",{});var br=i(Yt);iu=s(br,"If "),li=r(br,"CODE",{});var ty=i(li);lu=s(ty,"token_ids_1"),ty.forEach(t),du=s(br," is "),di=r(br,"CODE",{});var oy=i(di);cu=s(oy,"None"),oy.forEach(t),pu=s(br,", this method only returns the first portion of the mask (0s)."),br.forEach(t),fn.forEach(t),Ot.forEach(t),Wl=p(o),Zt=r(o,"H2",{class:!0});var Fd=i(Zt);Eo=r(Fd,"A",{id:!0,class:!0,href:!0});var ny=i(Eo);ci=r(ny,"SPAN",{});var sy=i(ci);L(ps.$$.fragment,sy),sy.forEach(t),ny.forEach(t),uu=p(Fd),pi=r(Fd,"SPAN",{});var ay=i(pi);hu=s(ay,"LayoutLMModel"),ay.forEach(t),Fd.forEach(t),Hl=p(o),ht=r(o,"DIV",{class:!0});var gn=i(ht);L(us.$$.fragment,gn),mu=p(gn),hs=r(gn,"P",{});var qd=i(hs);fu=s(qd,`The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top.
The LayoutLM model was proposed in `),ms=r(qd,"A",{href:!0,rel:!0});var ry=i(ms);gu=s(ry,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),ry.forEach(t),_u=s(qd,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),qd.forEach(t),yu=p(gn),fs=r(gn,"P",{});var Ed=i(fs);bu=s(Ed,"This model is a PyTorch "),gs=r(Ed,"A",{href:!0,rel:!0});var iy=i(gs);ku=s(iy,"torch.nn.Module"),iy.forEach(t),wu=s(Ed,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ed.forEach(t),vu=p(gn),kt=r(gn,"DIV",{class:!0});var _n=i(kt);L(_s.$$.fragment,_n),Lu=p(_n),Gt=r(_n,"P",{});var kr=i(Gt);Tu=s(kr,"The "),Ja=r(kr,"A",{href:!0});var ly=i(Ja);Mu=s(ly,"LayoutLMModel"),ly.forEach(t),$u=s(kr," forward method, overrides the "),ui=r(kr,"CODE",{});var dy=i(ui);xu=s(dy,"__call__"),dy.forEach(t),ju=s(kr," special method."),kr.forEach(t),Fu=p(_n),L(zo.$$.fragment,_n),qu=p(_n),L(Co.$$.fragment,_n),_n.forEach(t),gn.forEach(t),Kl=p(o),Jt=r(o,"H2",{class:!0});var zd=i(Jt);Ao=r(zd,"A",{id:!0,class:!0,href:!0});var cy=i(Ao);hi=r(cy,"SPAN",{});var py=i(hi);L(ys.$$.fragment,py),py.forEach(t),cy.forEach(t),Eu=p(zd),mi=r(zd,"SPAN",{});var uy=i(mi);zu=s(uy,"LayoutLMForMaskedLM"),uy.forEach(t),zd.forEach(t),Bl=p(o),mt=r(o,"DIV",{class:!0});var yn=i(mt);L(bs.$$.fragment,yn),Cu=p(yn),eo=r(yn,"P",{});var wr=i(eo);Au=s(wr,"LayoutLM Model with a "),fi=r(wr,"CODE",{});var hy=i(fi);Pu=s(hy,"language modeling"),hy.forEach(t),Du=s(wr,` head on top.
The LayoutLM model was proposed in `),ks=r(wr,"A",{href:!0,rel:!0});var my=i(ks);Nu=s(my,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),my.forEach(t),Ou=s(wr,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),wr.forEach(t),Iu=p(yn),ws=r(yn,"P",{});var Cd=i(ws);Su=s(Cd,"This model is a PyTorch "),vs=r(Cd,"A",{href:!0,rel:!0});var fy=i(vs);Uu=s(fy,"torch.nn.Module"),fy.forEach(t),Wu=s(Cd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Cd.forEach(t),Hu=p(yn),wt=r(yn,"DIV",{class:!0});var bn=i(wt);L(Ls.$$.fragment,bn),Ku=p(bn),to=r(bn,"P",{});var vr=i(to);Bu=s(vr,"The "),er=r(vr,"A",{href:!0});var gy=i(er);Qu=s(gy,"LayoutLMForMaskedLM"),gy.forEach(t),Ru=s(vr," forward method, overrides the "),gi=r(vr,"CODE",{});var _y=i(gi);Vu=s(_y,"__call__"),_y.forEach(t),Xu=s(vr," special method."),vr.forEach(t),Yu=p(bn),L(Po.$$.fragment,bn),Zu=p(bn),L(Do.$$.fragment,bn),bn.forEach(t),yn.forEach(t),Ql=p(o),oo=r(o,"H2",{class:!0});var Ad=i(oo);No=r(Ad,"A",{id:!0,class:!0,href:!0});var yy=i(No);_i=r(yy,"SPAN",{});var by=i(_i);L(Ts.$$.fragment,by),by.forEach(t),yy.forEach(t),Gu=p(Ad),yi=r(Ad,"SPAN",{});var ky=i(yi);Ju=s(ky,"LayoutLMForSequenceClassification"),ky.forEach(t),Ad.forEach(t),Rl=p(o),st=r(o,"DIV",{class:!0});var It=i(st);L(Ms.$$.fragment,It),eh=p(It),$s=r(It,"P",{});var Pd=i($s);th=s(Pd,`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 `),xs=r(Pd,"A",{href:!0,rel:!0});var wy=i(xs);oh=s(wy,"RVL-CDIP"),wy.forEach(t),nh=s(Pd," dataset."),Pd.forEach(t),sh=p(It),js=r(It,"P",{});var Dd=i(js);ah=s(Dd,"The LayoutLM model was proposed in "),Fs=r(Dd,"A",{href:!0,rel:!0});var vy=i(Fs);rh=s(vy,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),vy.forEach(t),ih=s(Dd,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Dd.forEach(t),lh=p(It),qs=r(It,"P",{});var Nd=i(qs);dh=s(Nd,"This model is a PyTorch "),Es=r(Nd,"A",{href:!0,rel:!0});var Ly=i(Es);ch=s(Ly,"torch.nn.Module"),Ly.forEach(t),ph=s(Nd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Nd.forEach(t),uh=p(It),vt=r(It,"DIV",{class:!0});var kn=i(vt);L(zs.$$.fragment,kn),hh=p(kn),no=r(kn,"P",{});var Lr=i(no);mh=s(Lr,"The "),tr=r(Lr,"A",{href:!0});var Ty=i(tr);fh=s(Ty,"LayoutLMForSequenceClassification"),Ty.forEach(t),gh=s(Lr," forward method, overrides the "),bi=r(Lr,"CODE",{});var My=i(bi);_h=s(My,"__call__"),My.forEach(t),yh=s(Lr," special method."),Lr.forEach(t),bh=p(kn),L(Oo.$$.fragment,kn),kh=p(kn),L(Io.$$.fragment,kn),kn.forEach(t),It.forEach(t),Vl=p(o),so=r(o,"H2",{class:!0});var Od=i(so);So=r(Od,"A",{id:!0,class:!0,href:!0});var $y=i(So);ki=r($y,"SPAN",{});var xy=i(ki);L(Cs.$$.fragment,xy),xy.forEach(t),$y.forEach(t),wh=p(Od),wi=r(Od,"SPAN",{});var jy=i(wi);vh=s(jy,"LayoutLMForTokenClassification"),jy.forEach(t),Od.forEach(t),Xl=p(o),at=r(o,"DIV",{class:!0});var St=i(at);L(As.$$.fragment,St),Lh=p(St),ao=r(St,"P",{});var Tr=i(ao);Th=s(Tr,`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 `),Ps=r(Tr,"A",{href:!0,rel:!0});var Fy=i(Ps);Mh=s(Fy,"FUNSD"),Fy.forEach(t),$h=s(Tr,`
dataset and the `),Ds=r(Tr,"A",{href:!0,rel:!0});var qy=i(Ds);xh=s(qy,"SROIE"),qy.forEach(t),jh=s(Tr," dataset."),Tr.forEach(t),Fh=p(St),Ns=r(St,"P",{});var Id=i(Ns);qh=s(Id,"The LayoutLM model was proposed in "),Os=r(Id,"A",{href:!0,rel:!0});var Ey=i(Os);Eh=s(Ey,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),Ey.forEach(t),zh=s(Id,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Id.forEach(t),Ch=p(St),Is=r(St,"P",{});var Sd=i(Is);Ah=s(Sd,"This model is a PyTorch "),Ss=r(Sd,"A",{href:!0,rel:!0});var zy=i(Ss);Ph=s(zy,"torch.nn.Module"),zy.forEach(t),Dh=s(Sd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Sd.forEach(t),Nh=p(St),Lt=r(St,"DIV",{class:!0});var wn=i(Lt);L(Us.$$.fragment,wn),Oh=p(wn),ro=r(wn,"P",{});var Mr=i(ro);Ih=s(Mr,"The "),or=r(Mr,"A",{href:!0});var Cy=i(or);Sh=s(Cy,"LayoutLMForTokenClassification"),Cy.forEach(t),Uh=s(Mr," forward method, overrides the "),vi=r(Mr,"CODE",{});var Ay=i(vi);Wh=s(Ay,"__call__"),Ay.forEach(t),Hh=s(Mr," special method."),Mr.forEach(t),Kh=p(wn),L(Uo.$$.fragment,wn),Bh=p(wn),L(Wo.$$.fragment,wn),wn.forEach(t),St.forEach(t),Yl=p(o),io=r(o,"H2",{class:!0});var Ud=i(io);Ho=r(Ud,"A",{id:!0,class:!0,href:!0});var Py=i(Ho);Li=r(Py,"SPAN",{});var Dy=i(Li);L(Ws.$$.fragment,Dy),Dy.forEach(t),Py.forEach(t),Qh=p(Ud),Ti=r(Ud,"SPAN",{});var Ny=i(Ti);Rh=s(Ny,"LayoutLMForQuestionAnswering"),Ny.forEach(t),Ud.forEach(t),Zl=p(o),rt=r(o,"DIV",{class:!0});var Ut=i(rt);L(Hs.$$.fragment,Ut),Vh=p(Ut),At=r(Ut,"P",{});var vn=i(At);Xh=s(vn,`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),Ks=r(vn,"A",{href:!0,rel:!0});var Oy=i(Ks);Yh=s(Oy,"DocVQA"),Oy.forEach(t),Zh=s(vn," (a linear layer on top of the final hidden-states output to compute "),Mi=r(vn,"CODE",{});var Iy=i(Mi);Gh=s(Iy,"span start logits"),Iy.forEach(t),Jh=s(vn," and "),$i=r(vn,"CODE",{});var Sy=i($i);em=s(Sy,"span end logits"),Sy.forEach(t),tm=s(vn,")."),vn.forEach(t),om=p(Ut),Bs=r(Ut,"P",{});var Wd=i(Bs);nm=s(Wd,"The LayoutLM model was proposed in "),Qs=r(Wd,"A",{href:!0,rel:!0});var Uy=i(Qs);sm=s(Uy,`LayoutLM: Pre-training of Text and Layout for Document Image
Understanding`),Uy.forEach(t),am=s(Wd,` by Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei and
Ming Zhou.`),Wd.forEach(t),rm=p(Ut),Rs=r(Ut,"P",{});var Hd=i(Rs);im=s(Hd,"This model is a PyTorch "),Vs=r(Hd,"A",{href:!0,rel:!0});var Wy=i(Vs);lm=s(Wy,"torch.nn.Module"),Wy.forEach(t),dm=s(Hd,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Hd.forEach(t),cm=p(Ut),dt=r(Ut,"DIV",{class:!0});var Wt=i(dt);L(Xs.$$.fragment,Wt),pm=p(Wt),De=r(Wt,"P",{});var Ye=i(De);um=s(Ye,"start_positions ("),xi=r(Ye,"CODE",{});var Hy=i(xi);hm=s(Hy,"torch.LongTensor"),Hy.forEach(t),mm=s(Ye," of shape "),ji=r(Ye,"CODE",{});var Ky=i(ji);fm=s(Ky,"(batch_size,)"),Ky.forEach(t),gm=s(Ye,", "),Fi=r(Ye,"EM",{});var By=i(Fi);_m=s(By,"optional"),By.forEach(t),ym=s(Ye,`):
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 (`),qi=r(Ye,"CODE",{});var Qy=i(qi);bm=s(Qy,"sequence_length"),Qy.forEach(t),km=s(Ye,`). Position outside of the sequence
are not taken into account for computing the loss.
end_positions (`),Ei=r(Ye,"CODE",{});var Ry=i(Ei);wm=s(Ry,"torch.LongTensor"),Ry.forEach(t),vm=s(Ye," of shape "),zi=r(Ye,"CODE",{});var Vy=i(zi);Lm=s(Vy,"(batch_size,)"),Vy.forEach(t),Tm=s(Ye,", "),Ci=r(Ye,"EM",{});var Xy=i(Ci);Mm=s(Xy,"optional"),Xy.forEach(t),$m=s(Ye,`):
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 (`),Ai=r(Ye,"CODE",{});var Yy=i(Ai);xm=s(Yy,"sequence_length"),Yy.forEach(t),jm=s(Ye,`). Position outside of the sequence
are not taken into account for computing the loss.`),Ye.forEach(t),Fm=p(Wt),Pi=r(Wt,"P",{});var Zy=i(Pi);qm=s(Zy,"Example:"),Zy.forEach(t),Em=p(Wt),Di=r(Wt,"P",{});var Gy=i(Di);zm=s(Gy,`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).`),Gy.forEach(t),Cm=p(Wt),L(Ko.$$.fragment,Wt),Wt.forEach(t),Ut.forEach(t),Gl=p(o),lo=r(o,"H2",{class:!0});var Kd=i(lo);Bo=r(Kd,"A",{id:!0,class:!0,href:!0});var Jy=i(Bo);Ni=r(Jy,"SPAN",{});var eb=i(Ni);L(Ys.$$.fragment,eb),eb.forEach(t),Jy.forEach(t),Am=p(Kd),Oi=r(Kd,"SPAN",{});var tb=i(Oi);Pm=s(tb,"TFLayoutLMModel"),tb.forEach(t),Kd.forEach(t),Jl=p(o),Ze=r(o,"DIV",{class:!0});var Ft=i(Ze);L(Zs.$$.fragment,Ft),Dm=p(Ft),Ii=r(Ft,"P",{});var ob=i(Ii);Nm=s(ob,"The bare LayoutLM Model transformer outputting raw hidden-states without any specific head on top."),ob.forEach(t),Om=p(Ft),Gs=r(Ft,"P",{});var Bd=i(Gs);Im=s(Bd,"This model inherits from "),nr=r(Bd,"A",{href:!0});var nb=i(nr);Sm=s(nb,"TFPreTrainedModel"),nb.forEach(t),Um=s(Bd,`. 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.)`),Bd.forEach(t),Wm=p(Ft),Js=r(Ft,"P",{});var Qd=i(Js);Hm=s(Qd,"This model is also a "),ea=r(Qd,"A",{href:!0,rel:!0});var sb=i(ea);Km=s(sb,"tf.keras.Model"),sb.forEach(t),Bm=s(Qd,` 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.`),Qd.forEach(t),Qm=p(Ft),L(Qo.$$.fragment,Ft),Rm=p(Ft),Tt=r(Ft,"DIV",{class:!0});var Ln=i(Tt);L(ta.$$.fragment,Ln),Vm=p(Ln),co=r(Ln,"P",{});var $r=i(co);Xm=s($r,"The "),sr=r($r,"A",{href:!0});var ab=i(sr);Ym=s(ab,"TFLayoutLMModel"),ab.forEach(t),Zm=s($r," forward method, overrides the "),Si=r($r,"CODE",{});var rb=i(Si);Gm=s(rb,"__call__"),rb.forEach(t),Jm=s($r," special method."),$r.forEach(t),ef=p(Ln),L(Ro.$$.fragment,Ln),tf=p(Ln),L(Vo.$$.fragment,Ln),Ln.forEach(t),Ft.forEach(t),ed=p(o),po=r(o,"H2",{class:!0});var Rd=i(po);Xo=r(Rd,"A",{id:!0,class:!0,href:!0});var ib=i(Xo);Ui=r(ib,"SPAN",{});var lb=i(Ui);L(oa.$$.fragment,lb),lb.forEach(t),ib.forEach(t),of=p(Rd),Wi=r(Rd,"SPAN",{});var db=i(Wi);nf=s(db,"TFLayoutLMForMaskedLM"),db.forEach(t),Rd.forEach(t),td=p(o),Ge=r(o,"DIV",{class:!0});var qt=i(Ge);L(na.$$.fragment,qt),sf=p(qt),sa=r(qt,"P",{});var Vd=i(sa);af=s(Vd,"LayoutLM Model with a "),Hi=r(Vd,"CODE",{});var cb=i(Hi);rf=s(cb,"language modeling"),cb.forEach(t),lf=s(Vd," head on top."),Vd.forEach(t),df=p(qt),aa=r(qt,"P",{});var Xd=i(aa);cf=s(Xd,"This model inherits from "),ar=r(Xd,"A",{href:!0});var pb=i(ar);pf=s(pb,"TFPreTrainedModel"),pb.forEach(t),uf=s(Xd,`. 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.)`),Xd.forEach(t),hf=p(qt),ra=r(qt,"P",{});var Yd=i(ra);mf=s(Yd,"This model is also a "),ia=r(Yd,"A",{href:!0,rel:!0});var ub=i(ia);ff=s(ub,"tf.keras.Model"),ub.forEach(t),gf=s(Yd,` 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.`),Yd.forEach(t),_f=p(qt),L(Yo.$$.fragment,qt),yf=p(qt),Mt=r(qt,"DIV",{class:!0});var Tn=i(Mt);L(la.$$.fragment,Tn),bf=p(Tn),uo=r(Tn,"P",{});var xr=i(uo);kf=s(xr,"The "),rr=r(xr,"A",{href:!0});var hb=i(rr);wf=s(hb,"TFLayoutLMForMaskedLM"),hb.forEach(t),vf=s(xr," forward method, overrides the "),Ki=r(xr,"CODE",{});var mb=i(Ki);Lf=s(mb,"__call__"),mb.forEach(t),Tf=s(xr," special method."),xr.forEach(t),Mf=p(Tn),L(Zo.$$.fragment,Tn),$f=p(Tn),L(Go.$$.fragment,Tn),Tn.forEach(t),qt.forEach(t),od=p(o),ho=r(o,"H2",{class:!0});var Zd=i(ho);Jo=r(Zd,"A",{id:!0,class:!0,href:!0});var fb=i(Jo);Bi=r(fb,"SPAN",{});var gb=i(Bi);L(da.$$.fragment,gb),gb.forEach(t),fb.forEach(t),xf=p(Zd),Qi=r(Zd,"SPAN",{});var _b=i(Qi);jf=s(_b,"TFLayoutLMForSequenceClassification"),_b.forEach(t),Zd.forEach(t),nd=p(o),Je=r(o,"DIV",{class:!0});var Et=i(Je);L(ca.$$.fragment,Et),Ff=p(Et),Ri=r(Et,"P",{});var yb=i(Ri);qf=s(yb,`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.`),yb.forEach(t),Ef=p(Et),pa=r(Et,"P",{});var Gd=i(pa);zf=s(Gd,"This model inherits from "),ir=r(Gd,"A",{href:!0});var bb=i(ir);Cf=s(bb,"TFPreTrainedModel"),bb.forEach(t),Af=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),Pf=p(Et),ua=r(Et,"P",{});var Jd=i(ua);Df=s(Jd,"This model is also a "),ha=r(Jd,"A",{href:!0,rel:!0});var kb=i(ha);Nf=s(kb,"tf.keras.Model"),kb.forEach(t),Of=s(Jd,` 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.`),Jd.forEach(t),If=p(Et),L(en.$$.fragment,Et),Sf=p(Et),$t=r(Et,"DIV",{class:!0});var Mn=i($t);L(ma.$$.fragment,Mn),Uf=p(Mn),mo=r(Mn,"P",{});var jr=i(mo);Wf=s(jr,"The "),lr=r(jr,"A",{href:!0});var wb=i(lr);Hf=s(wb,"TFLayoutLMForSequenceClassification"),wb.forEach(t),Kf=s(jr," forward method, overrides the "),Vi=r(jr,"CODE",{});var vb=i(Vi);Bf=s(vb,"__call__"),vb.forEach(t),Qf=s(jr," special method."),jr.forEach(t),Rf=p(Mn),L(tn.$$.fragment,Mn),Vf=p(Mn),L(on.$$.fragment,Mn),Mn.forEach(t),Et.forEach(t),sd=p(o),fo=r(o,"H2",{class:!0});var ec=i(fo);nn=r(ec,"A",{id:!0,class:!0,href:!0});var Lb=i(nn);Xi=r(Lb,"SPAN",{});var Tb=i(Xi);L(fa.$$.fragment,Tb),Tb.forEach(t),Lb.forEach(t),Xf=p(ec),Yi=r(ec,"SPAN",{});var Mb=i(Yi);Yf=s(Mb,"TFLayoutLMForTokenClassification"),Mb.forEach(t),ec.forEach(t),ad=p(o),et=r(o,"DIV",{class:!0});var zt=i(et);L(ga.$$.fragment,zt),Zf=p(zt),Zi=r(zt,"P",{});var $b=i(Zi);Gf=s($b,`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.`),$b.forEach(t),Jf=p(zt),_a=r(zt,"P",{});var tc=i(_a);eg=s(tc,"This model inherits from "),dr=r(tc,"A",{href:!0});var xb=i(dr);tg=s(xb,"TFPreTrainedModel"),xb.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(zt),ya=r(zt,"P",{});var oc=i(ya);sg=s(oc,"This model is also a "),ba=r(oc,"A",{href:!0,rel:!0});var jb=i(ba);ag=s(jb,"tf.keras.Model"),jb.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),ig=p(zt),L(sn.$$.fragment,zt),lg=p(zt),xt=r(zt,"DIV",{class:!0});var $n=i(xt);L(ka.$$.fragment,$n),dg=p($n),go=r($n,"P",{});var Fr=i(go);cg=s(Fr,"The "),cr=r(Fr,"A",{href:!0});var Fb=i(cr);pg=s(Fb,"TFLayoutLMForTokenClassification"),Fb.forEach(t),ug=s(Fr," forward method, overrides the "),Gi=r(Fr,"CODE",{});var qb=i(Gi);hg=s(qb,"__call__"),qb.forEach(t),mg=s(Fr," special method."),Fr.forEach(t),fg=p($n),L(an.$$.fragment,$n),gg=p($n),L(rn.$$.fragment,$n),$n.forEach(t),zt.forEach(t),rd=p(o),_o=r(o,"H2",{class:!0});var nc=i(_o);ln=r(nc,"A",{id:!0,class:!0,href:!0});var Eb=i(ln);Ji=r(Eb,"SPAN",{});var zb=i(Ji);L(wa.$$.fragment,zb),zb.forEach(t),Eb.forEach(t),_g=p(nc),el=r(nc,"SPAN",{});var Cb=i(el);yg=s(Cb,"TFLayoutLMForQuestionAnswering"),Cb.forEach(t),nc.forEach(t),id=p(o),tt=r(o,"DIV",{class:!0});var Ct=i(tt);L(va.$$.fragment,Ct),bg=p(Ct),Pt=r(Ct,"P",{});var xn=i(Pt);kg=s(xn,`LayoutLM Model with a span classification head on top for extractive question-answering tasks such as
`),La=r(xn,"A",{href:!0,rel:!0});var Ab=i(La);wg=s(Ab,"DocVQA"),Ab.forEach(t),vg=s(xn," (a linear layer on top of the final hidden-states output to compute "),tl=r(xn,"CODE",{});var Pb=i(tl);Lg=s(Pb,"span start logits"),Pb.forEach(t),Tg=s(xn," and "),ol=r(xn,"CODE",{});var Db=i(ol);Mg=s(Db,"span end logits"),Db.forEach(t),$g=s(xn,")."),xn.forEach(t),xg=p(Ct),Ta=r(Ct,"P",{});var sc=i(Ta);jg=s(sc,"This model inherits from "),pr=r(sc,"A",{href:!0});var Nb=i(pr);Fg=s(Nb,"TFPreTrainedModel"),Nb.forEach(t),qg=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),Eg=p(Ct),Ma=r(Ct,"P",{});var ac=i(Ma);zg=s(ac,"This model is also a "),$a=r(ac,"A",{href:!0,rel:!0});var Ob=i($a);Cg=s(Ob,"tf.keras.Model"),Ob.forEach(t),Ag=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),Pg=p(Ct),L(dn.$$.fragment,Ct),Dg=p(Ct),jt=r(Ct,"DIV",{class:!0});var jn=i(jt);L(xa.$$.fragment,jn),Ng=p(jn),yo=r(jn,"P",{});var qr=i(yo);Og=s(qr,"The "),ur=r(qr,"A",{href:!0});var Ib=i(ur);Ig=s(Ib,"TFLayoutLMForQuestionAnswering"),Ib.forEach(t),Sg=s(qr," forward method, overrides the "),nl=r(qr,"CODE",{});var Sb=i(nl);Ug=s(Sb,"__call__"),Sb.forEach(t),Wg=s(qr," special method."),qr.forEach(t),Hg=p(jn),L(cn.$$.fragment,jn),Kg=p(jn),L(pn.$$.fragment,jn),jn.forEach(t),Ct.forEach(t),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(kk)),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(w,"id","overview"),u(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(w,"href","#overview"),u(B,"class","relative group"),u(ie,"href","https://arxiv.org/abs/1912.13318"),u(ie,"rel","nofollow"),u(le,"href","https://guillaumejaume.github.io/FUNSD/"),u(le,"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/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMModel.forward"),u(Pe,"href","https://github.com/tesseract-ocr/tesseract"),u(Pe,"rel","nofollow"),u(N,"href","https://pypi.org/project/pytesseract/"),u(N,"rel","nofollow"),u(ko,"id","resources"),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","#resources"),u(Ht,"class","relative group"),u(Cn,"href","https://www.philschmid.de/fine-tuning-layoutlm-keras"),u(Cn,"rel","nofollow"),u(Pn,"href","https://www.philschmid.de/fine-tuning-layoutlm"),u(Pn,"rel","nofollow"),u(Nn,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLM/Add_image_embeddings_to_LayoutLM.ipynb"),u(Nn,"rel","nofollow"),u(Da,"href","../tasks/document_question_answering"),u(Sn,"href","https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/LayoutLM/Fine_tuning_LayoutLMForSequenceClassification_on_RVL_CDIP.ipynb"),u(Sn,"rel","nofollow"),u(Na,"href","../tasks/sequence_classification"),u(Hn,"href","https://github.com/NielsRogge/Transformers-Tutorials/blob/master/LayoutLM/Fine_tuning_LayoutLMForTokenClassification_on_FUNSD.ipynb"),u(Hn,"rel","nofollow"),u(Oa,"href","../tasks/token_classification"),u(Ua,"href","../tasks/masked_language_modeling"),u(Bn,"href","https://www.philschmid.de/inference-endpoints-layoutlm"),u(Bn,"rel","nofollow"),u(Lo,"id","transformers.LayoutLMConfig"),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.LayoutLMConfig"),u(Kt,"class","relative group"),u(Ka,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMModel"),u(Vn,"href","https://huggingface.co/microsoft/layoutlm-base-uncased"),u(Vn,"rel","nofollow"),u(Ba,"href","/docs/transformers/v4.29.0/en/model_doc/bert#transformers.BertConfig"),u(Qa,"href","/docs/transformers/v4.29.0/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(Mo,"id","transformers.LayoutLMTokenizer"),u(Mo,"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(Mo,"href","#transformers.LayoutLMTokenizer"),u(Rt,"class","relative group"),u(Ra,"href","/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),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($o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(yt,"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(Se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Fo,"id","transformers.LayoutLMTokenizerFast"),u(Fo,"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(Fo,"href","#transformers.LayoutLMTokenizerFast"),u(Xt,"class","relative group"),u(Ya,"href","/docs/transformers/v4.29.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),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(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(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(Eo,"id","transformers.LayoutLMModel"),u(Eo,"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(Eo,"href","#transformers.LayoutLMModel"),u(Zt,"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(Ja,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMModel"),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(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(Ao,"id","transformers.LayoutLMForMaskedLM"),u(Ao,"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(Ao,"href","#transformers.LayoutLMForMaskedLM"),u(Jt,"class","relative group"),u(ks,"href","https://arxiv.org/abs/1912.13318"),u(ks,"rel","nofollow"),u(vs,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(vs,"rel","nofollow"),u(er,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMForMaskedLM"),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(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(No,"id","transformers.LayoutLMForSequenceClassification"),u(No,"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(No,"href","#transformers.LayoutLMForSequenceClassification"),u(oo,"class","relative group"),u(xs,"href","https://www.cs.cmu.edu/~aharley/rvl-cdip/"),u(xs,"rel","nofollow"),u(Fs,"href","https://arxiv.org/abs/1912.13318"),u(Fs,"rel","nofollow"),u(Es,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Es,"rel","nofollow"),u(tr,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMForSequenceClassification"),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(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(So,"id","transformers.LayoutLMForTokenClassification"),u(So,"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(So,"href","#transformers.LayoutLMForTokenClassification"),u(so,"class","relative group"),u(Ps,"href","https://guillaumejaume.github.io/FUNSD/"),u(Ps,"rel","nofollow"),u(Ds,"href","https://rrc.cvc.uab.es/?ch=13"),u(Ds,"rel","nofollow"),u(Os,"href","https://arxiv.org/abs/1912.13318"),u(Os,"rel","nofollow"),u(Ss,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Ss,"rel","nofollow"),u(or,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.LayoutLMForTokenClassification"),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(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(Ho,"id","transformers.LayoutLMForQuestionAnswering"),u(Ho,"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(Ho,"href","#transformers.LayoutLMForQuestionAnswering"),u(io,"class","relative group"),u(Ks,"href","https://rrc.cvc.uab.es/?ch=17"),u(Ks,"rel","nofollow"),u(Qs,"href","https://arxiv.org/abs/1912.13318"),u(Qs,"rel","nofollow"),u(Vs,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Vs,"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(Bo,"id","transformers.TFLayoutLMModel"),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","#transformers.TFLayoutLMModel"),u(lo,"class","relative group"),u(nr,"href","/docs/transformers/v4.29.0/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/v4.29.0/en/model_doc/layoutlm#transformers.TFLayoutLMModel"),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(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(Xo,"id","transformers.TFLayoutLMForMaskedLM"),u(Xo,"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(Xo,"href","#transformers.TFLayoutLMForMaskedLM"),u(po,"class","relative group"),u(ar,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel"),u(ia,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(ia,"rel","nofollow"),u(rr,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.TFLayoutLMForMaskedLM"),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(Ge,"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,"id","transformers.TFLayoutLMForSequenceClassification"),u(Jo,"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(Jo,"href","#transformers.TFLayoutLMForSequenceClassification"),u(ho,"class","relative group"),u(ir,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel"),u(ha,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(ha,"rel","nofollow"),u(lr,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.TFLayoutLMForSequenceClassification"),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(Je,"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/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel"),u(ba,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(ba,"rel","nofollow"),u(cr,"href","/docs/transformers/v4.29.0/en/model_doc/layoutlm#transformers.TFLayoutLMForTokenClassification"),u(xt,"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(_o,"class","relative group"),u(La,"href","https://rrc.cvc.uab.es/?ch=17"),u(La,"rel","nofollow"),u(pr,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel"),u($a,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u($a,"rel","nofollow"),u(ur,"href","/docs/transformers/v4.29.0/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,_){e(document.head,d),m(o,k,_),m(o,f,_),e(f,g),e(g,b),T(l,b,null),e(f,h),e(f,q),e(q,Me),m(o,_e,_),m(o,W,_),m(o,ye,_),m(o,B,_),e(B,w),e(w,he),T(I,he,null),e(B,$e),e(B,me),e(me,Q),m(o,be,_),m(o,se,_),e(se,R),e(se,ie),e(ie,xe),e(se,V),m(o,ke,_),m(o,oe,_),e(oe,S),e(S,je),e(S,le),e(le,ae),e(S,E),e(oe,C),e(oe,de),e(de,X),e(de,ce),e(ce,Fe),e(de,Y),e(oe,qe),e(oe,pe),e(pe,A),e(pe,ue),e(ue,Z),e(pe,Ee),m(o,we,_),m(o,H,_),e(H,ze),m(o,ve,_),m(o,O,_),e(O,fe),e(fe,G),m(o,Le,_),m(o,ee,_),e(ee,P),m(o,Te,_),m(o,D,_),e(D,K),e(K,Ce),e(K,y),e(y,j),e(K,Ue),e(K,te),e(te,We),e(K,He),e(K,F),e(F,Ke),e(K,Be),e(K,Pe),e(Pe,Qe),e(K,Re),e(K,N),e(N,J),e(K,Ve),m(o,Oe,_),T(U,o,_),m(o,Ie,_),m(o,ge,_),e(ge,Ae),e(ge,Ne),e(Ne,re),e(ge,Xe),e(ge,Er),e(Er,rc),e(ge,ic),m(o,Ll,_),T(Fn,o,_),m(o,Tl,_),m(o,Ht,_),e(Ht,ko),e(ko,zr),T(qn,zr,null),e(Ht,lc),e(Ht,Cr),e(Cr,dc),m(o,Ml,_),m(o,Aa,_),e(Aa,cc),m(o,$l,_),T(En,o,_),m(o,xl,_),m(o,_t,_),e(_t,Ar),e(Ar,zn),e(zn,pc),e(zn,Cn),e(Cn,uc),e(zn,hc),e(_t,mc),e(_t,Pr),e(Pr,An),e(An,fc),e(An,Pn),e(Pn,gc),e(An,_c),e(_t,yc),e(_t,Dr),e(Dr,Dn),e(Dn,bc),e(Dn,Nn),e(Nn,kc),e(Dn,wc),e(_t,vc),e(_t,Nr),e(Nr,Pa),e(Pa,Lc),e(Pa,Da),e(Da,Tc),m(o,jl,_),T(On,o,_),m(o,Fl,_),m(o,wo,_),e(wo,In),e(In,Mc),e(In,Sn),e(Sn,$c),e(In,xc),e(wo,jc),e(wo,Or),e(Or,Na),e(Na,Fc),m(o,ql,_),T(Un,o,_),m(o,El,_),m(o,vo,_),e(vo,Wn),e(Wn,qc),e(Wn,Hn),e(Hn,Ec),e(Wn,zc),e(vo,Cc),e(vo,Ir),e(Ir,Oa),e(Oa,Ac),m(o,zl,_),m(o,Ia,_),e(Ia,Sr),e(Sr,Pc),m(o,Cl,_),m(o,Sa,_),e(Sa,Ur),e(Ur,Ua),e(Ua,Dc),m(o,Al,_),m(o,Wa,_),e(Wa,Nc),m(o,Pl,_),m(o,Ha,_),e(Ha,Kn),e(Kn,Oc),e(Kn,Bn),e(Bn,Ic),e(Kn,Sc),m(o,Dl,_),m(o,Kt,_),e(Kt,Lo),e(Lo,Wr),T(Qn,Wr,null),e(Kt,Uc),e(Kt,Hr),e(Hr,Wc),m(o,Nl,_),m(o,ut,_),T(Rn,ut,null),e(ut,Hc),e(ut,Bt),e(Bt,Kc),e(Bt,Ka),e(Ka,Bc),e(Bt,Qc),e(Bt,Vn),e(Vn,Rc),e(Bt,Vc),e(ut,Xc),e(ut,Qt),e(Qt,Yc),e(Qt,Ba),e(Ba,Zc),e(Qt,Gc),e(Qt,Qa),e(Qa,Jc),e(Qt,ep),e(ut,tp),T(To,ut,null),m(o,Ol,_),m(o,Rt,_),e(Rt,Mo),e(Mo,Kr),T(Xn,Kr,null),e(Rt,op),e(Rt,Br),e(Br,np),m(o,Il,_),m(o,Se,_),T(Yn,Se,null),e(Se,sp),e(Se,Qr),e(Qr,ap),e(Se,rp),e(Se,Zn),e(Zn,ip),e(Zn,Ra),e(Ra,lp),e(Zn,dp),e(Se,cp),e(Se,Dt),T(Gn,Dt,null),e(Dt,pp),e(Dt,Rr),e(Rr,up),e(Dt,hp),e(Dt,Jn),e(Jn,Va),e(Va,mp),e(Va,Vr),e(Vr,fp),e(Jn,gp),e(Jn,Xa),e(Xa,_p),e(Xa,Xr),e(Xr,yp),e(Se,bp),e(Se,$o),T(es,$o,null),e($o,kp),e($o,Yr),e(Yr,wp),e(Se,vp),e(Se,yt),T(ts,yt,null),e(yt,Lp),e(yt,Zr),e(Zr,Tp),e(yt,Mp),T(xo,yt,null),e(yt,$p),e(yt,Vt),e(Vt,xp),e(Vt,Gr),e(Gr,jp),e(Vt,Fp),e(Vt,Jr),e(Jr,qp),e(Vt,Ep),e(Se,zp),e(Se,jo),T(os,jo,null),e(jo,Cp),e(jo,ns),e(ns,Ap),e(ns,ei),e(ei,Pp),e(ns,Dp),m(o,Sl,_),m(o,Xt,_),e(Xt,Fo),e(Fo,ti),T(ss,ti,null),e(Xt,Np),e(Xt,oi),e(oi,Op),m(o,Ul,_),m(o,nt,_),T(as,nt,null),e(nt,Ip),e(nt,rs),e(rs,Sp),e(rs,ni),e(ni,Up),e(rs,Wp),e(nt,Hp),e(nt,is),e(is,Kp),e(is,Ya),e(Ya,Bp),e(is,Qp),e(nt,Rp),e(nt,Nt),T(ls,Nt,null),e(Nt,Vp),e(Nt,si),e(si,Xp),e(Nt,Yp),e(Nt,ds),e(ds,Za),e(Za,Zp),e(Za,ai),e(ai,Gp),e(ds,Jp),e(ds,Ga),e(Ga,eu),e(Ga,ri),e(ri,tu),e(nt,ou),e(nt,bt),T(cs,bt,null),e(bt,nu),e(bt,ii),e(ii,su),e(bt,au),T(qo,bt,null),e(bt,ru),e(bt,Yt),e(Yt,iu),e(Yt,li),e(li,lu),e(Yt,du),e(Yt,di),e(di,cu),e(Yt,pu),m(o,Wl,_),m(o,Zt,_),e(Zt,Eo),e(Eo,ci),T(ps,ci,null),e(Zt,uu),e(Zt,pi),e(pi,hu),m(o,Hl,_),m(o,ht,_),T(us,ht,null),e(ht,mu),e(ht,hs),e(hs,fu),e(hs,ms),e(ms,gu),e(hs,_u),e(ht,yu),e(ht,fs),e(fs,bu),e(fs,gs),e(gs,ku),e(fs,wu),e(ht,vu),e(ht,kt),T(_s,kt,null),e(kt,Lu),e(kt,Gt),e(Gt,Tu),e(Gt,Ja),e(Ja,Mu),e(Gt,$u),e(Gt,ui),e(ui,xu),e(Gt,ju),e(kt,Fu),T(zo,kt,null),e(kt,qu),T(Co,kt,null),m(o,Kl,_),m(o,Jt,_),e(Jt,Ao),e(Ao,hi),T(ys,hi,null),e(Jt,Eu),e(Jt,mi),e(mi,zu),m(o,Bl,_),m(o,mt,_),T(bs,mt,null),e(mt,Cu),e(mt,eo),e(eo,Au),e(eo,fi),e(fi,Pu),e(eo,Du),e(eo,ks),e(ks,Nu),e(eo,Ou),e(mt,Iu),e(mt,ws),e(ws,Su),e(ws,vs),e(vs,Uu),e(ws,Wu),e(mt,Hu),e(mt,wt),T(Ls,wt,null),e(wt,Ku),e(wt,to),e(to,Bu),e(to,er),e(er,Qu),e(to,Ru),e(to,gi),e(gi,Vu),e(to,Xu),e(wt,Yu),T(Po,wt,null),e(wt,Zu),T(Do,wt,null),m(o,Ql,_),m(o,oo,_),e(oo,No),e(No,_i),T(Ts,_i,null),e(oo,Gu),e(oo,yi),e(yi,Ju),m(o,Rl,_),m(o,st,_),T(Ms,st,null),e(st,eh),e(st,$s),e($s,th),e($s,xs),e(xs,oh),e($s,nh),e(st,sh),e(st,js),e(js,ah),e(js,Fs),e(Fs,rh),e(js,ih),e(st,lh),e(st,qs),e(qs,dh),e(qs,Es),e(Es,ch),e(qs,ph),e(st,uh),e(st,vt),T(zs,vt,null),e(vt,hh),e(vt,no),e(no,mh),e(no,tr),e(tr,fh),e(no,gh),e(no,bi),e(bi,_h),e(no,yh),e(vt,bh),T(Oo,vt,null),e(vt,kh),T(Io,vt,null),m(o,Vl,_),m(o,so,_),e(so,So),e(So,ki),T(Cs,ki,null),e(so,wh),e(so,wi),e(wi,vh),m(o,Xl,_),m(o,at,_),T(As,at,null),e(at,Lh),e(at,ao),e(ao,Th),e(ao,Ps),e(Ps,Mh),e(ao,$h),e(ao,Ds),e(Ds,xh),e(ao,jh),e(at,Fh),e(at,Ns),e(Ns,qh),e(Ns,Os),e(Os,Eh),e(Ns,zh),e(at,Ch),e(at,Is),e(Is,Ah),e(Is,Ss),e(Ss,Ph),e(Is,Dh),e(at,Nh),e(at,Lt),T(Us,Lt,null),e(Lt,Oh),e(Lt,ro),e(ro,Ih),e(ro,or),e(or,Sh),e(ro,Uh),e(ro,vi),e(vi,Wh),e(ro,Hh),e(Lt,Kh),T(Uo,Lt,null),e(Lt,Bh),T(Wo,Lt,null),m(o,Yl,_),m(o,io,_),e(io,Ho),e(Ho,Li),T(Ws,Li,null),e(io,Qh),e(io,Ti),e(Ti,Rh),m(o,Zl,_),m(o,rt,_),T(Hs,rt,null),e(rt,Vh),e(rt,At),e(At,Xh),e(At,Ks),e(Ks,Yh),e(At,Zh),e(At,Mi),e(Mi,Gh),e(At,Jh),e(At,$i),e($i,em),e(At,tm),e(rt,om),e(rt,Bs),e(Bs,nm),e(Bs,Qs),e(Qs,sm),e(Bs,am),e(rt,rm),e(rt,Rs),e(Rs,im),e(Rs,Vs),e(Vs,lm),e(Rs,dm),e(rt,cm),e(rt,dt),T(Xs,dt,null),e(dt,pm),e(dt,De),e(De,um),e(De,xi),e(xi,hm),e(De,mm),e(De,ji),e(ji,fm),e(De,gm),e(De,Fi),e(Fi,_m),e(De,ym),e(De,qi),e(qi,bm),e(De,km),e(De,Ei),e(Ei,wm),e(De,vm),e(De,zi),e(zi,Lm),e(De,Tm),e(De,Ci),e(Ci,Mm),e(De,$m),e(De,Ai),e(Ai,xm),e(De,jm),e(dt,Fm),e(dt,Pi),e(Pi,qm),e(dt,Em),e(dt,Di),e(Di,zm),e(dt,Cm),T(Ko,dt,null),m(o,Gl,_),m(o,lo,_),e(lo,Bo),e(Bo,Ni),T(Ys,Ni,null),e(lo,Am),e(lo,Oi),e(Oi,Pm),m(o,Jl,_),m(o,Ze,_),T(Zs,Ze,null),e(Ze,Dm),e(Ze,Ii),e(Ii,Nm),e(Ze,Om),e(Ze,Gs),e(Gs,Im),e(Gs,nr),e(nr,Sm),e(Gs,Um),e(Ze,Wm),e(Ze,Js),e(Js,Hm),e(Js,ea),e(ea,Km),e(Js,Bm),e(Ze,Qm),T(Qo,Ze,null),e(Ze,Rm),e(Ze,Tt),T(ta,Tt,null),e(Tt,Vm),e(Tt,co),e(co,Xm),e(co,sr),e(sr,Ym),e(co,Zm),e(co,Si),e(Si,Gm),e(co,Jm),e(Tt,ef),T(Ro,Tt,null),e(Tt,tf),T(Vo,Tt,null),m(o,ed,_),m(o,po,_),e(po,Xo),e(Xo,Ui),T(oa,Ui,null),e(po,of),e(po,Wi),e(Wi,nf),m(o,td,_),m(o,Ge,_),T(na,Ge,null),e(Ge,sf),e(Ge,sa),e(sa,af),e(sa,Hi),e(Hi,rf),e(sa,lf),e(Ge,df),e(Ge,aa),e(aa,cf),e(aa,ar),e(ar,pf),e(aa,uf),e(Ge,hf),e(Ge,ra),e(ra,mf),e(ra,ia),e(ia,ff),e(ra,gf),e(Ge,_f),T(Yo,Ge,null),e(Ge,yf),e(Ge,Mt),T(la,Mt,null),e(Mt,bf),e(Mt,uo),e(uo,kf),e(uo,rr),e(rr,wf),e(uo,vf),e(uo,Ki),e(Ki,Lf),e(uo,Tf),e(Mt,Mf),T(Zo,Mt,null),e(Mt,$f),T(Go,Mt,null),m(o,od,_),m(o,ho,_),e(ho,Jo),e(Jo,Bi),T(da,Bi,null),e(ho,xf),e(ho,Qi),e(Qi,jf),m(o,nd,_),m(o,Je,_),T(ca,Je,null),e(Je,Ff),e(Je,Ri),e(Ri,qf),e(Je,Ef),e(Je,pa),e(pa,zf),e(pa,ir),e(ir,Cf),e(pa,Af),e(Je,Pf),e(Je,ua),e(ua,Df),e(ua,ha),e(ha,Nf),e(ua,Of),e(Je,If),T(en,Je,null),e(Je,Sf),e(Je,$t),T(ma,$t,null),e($t,Uf),e($t,mo),e(mo,Wf),e(mo,lr),e(lr,Hf),e(mo,Kf),e(mo,Vi),e(Vi,Bf),e(mo,Qf),e($t,Rf),T(tn,$t,null),e($t,Vf),T(on,$t,null),m(o,sd,_),m(o,fo,_),e(fo,nn),e(nn,Xi),T(fa,Xi,null),e(fo,Xf),e(fo,Yi),e(Yi,Yf),m(o,ad,_),m(o,et,_),T(ga,et,null),e(et,Zf),e(et,Zi),e(Zi,Gf),e(et,Jf),e(et,_a),e(_a,eg),e(_a,dr),e(dr,tg),e(_a,og),e(et,ng),e(et,ya),e(ya,sg),e(ya,ba),e(ba,ag),e(ya,rg),e(et,ig),T(sn,et,null),e(et,lg),e(et,xt),T(ka,xt,null),e(xt,dg),e(xt,go),e(go,cg),e(go,cr),e(cr,pg),e(go,ug),e(go,Gi),e(Gi,hg),e(go,mg),e(xt,fg),T(an,xt,null),e(xt,gg),T(rn,xt,null),m(o,rd,_),m(o,_o,_),e(_o,ln),e(ln,Ji),T(wa,Ji,null),e(_o,_g),e(_o,el),e(el,yg),m(o,id,_),m(o,tt,_),T(va,tt,null),e(tt,bg),e(tt,Pt),e(Pt,kg),e(Pt,La),e(La,wg),e(Pt,vg),e(Pt,tl),e(tl,Lg),e(Pt,Tg),e(Pt,ol),e(ol,Mg),e(Pt,$g),e(tt,xg),e(tt,Ta),e(Ta,jg),e(Ta,pr),e(pr,Fg),e(Ta,qg),e(tt,Eg),e(tt,Ma),e(Ma,zg),e(Ma,$a),e($a,Cg),e(Ma,Ag),e(tt,Pg),T(dn,tt,null),e(tt,Dg),e(tt,jt),T(xa,jt,null),e(jt,Ng),e(jt,yo),e(yo,Og),e(yo,ur),e(ur,Ig),e(yo,Sg),e(yo,nl),e(nl,Ug),e(yo,Wg),e(jt,Hg),T(cn,jt,null),e(jt,Kg),T(pn,jt,null),ld=!0},p(o,[_]){const ja={};_&2&&(ja.$$scope={dirty:_,ctx:o}),To.$set(ja);const sl={};_&2&&(sl.$$scope={dirty:_,ctx:o}),xo.$set(sl);const al={};_&2&&(al.$$scope={dirty:_,ctx:o}),qo.$set(al);const rl={};_&2&&(rl.$$scope={dirty:_,ctx:o}),zo.$set(rl);const Fa={};_&2&&(Fa.$$scope={dirty:_,ctx:o}),Co.$set(Fa);const il={};_&2&&(il.$$scope={dirty:_,ctx:o}),Po.$set(il);const ll={};_&2&&(ll.$$scope={dirty:_,ctx:o}),Do.$set(ll);const dl={};_&2&&(dl.$$scope={dirty:_,ctx:o}),Oo.$set(dl);const qa={};_&2&&(qa.$$scope={dirty:_,ctx:o}),Io.$set(qa);const cl={};_&2&&(cl.$$scope={dirty:_,ctx:o}),Uo.$set(cl);const bo={};_&2&&(bo.$$scope={dirty:_,ctx:o}),Wo.$set(bo);const Ea={};_&2&&(Ea.$$scope={dirty:_,ctx:o}),Ko.$set(Ea);const pl={};_&2&&(pl.$$scope={dirty:_,ctx:o}),Qo.$set(pl);const za={};_&2&&(za.$$scope={dirty:_,ctx:o}),Ro.$set(za);const ul={};_&2&&(ul.$$scope={dirty:_,ctx:o}),Vo.$set(ul);const Ca={};_&2&&(Ca.$$scope={dirty:_,ctx:o}),Yo.$set(Ca);const hl={};_&2&&(hl.$$scope={dirty:_,ctx:o}),Zo.$set(hl);const ml={};_&2&&(ml.$$scope={dirty:_,ctx:o}),Go.$set(ml);const fl={};_&2&&(fl.$$scope={dirty:_,ctx:o}),en.$set(fl);const gl={};_&2&&(gl.$$scope={dirty:_,ctx:o}),tn.$set(gl);const _l={};_&2&&(_l.$$scope={dirty:_,ctx:o}),on.$set(_l);const yl={};_&2&&(yl.$$scope={dirty:_,ctx:o}),sn.$set(yl);const it={};_&2&&(it.$$scope={dirty:_,ctx:o}),an.$set(it);const bl={};_&2&&(bl.$$scope={dirty:_,ctx:o}),rn.$set(bl);const kl={};_&2&&(kl.$$scope={dirty:_,ctx:o}),dn.$set(kl);const wl={};_&2&&(wl.$$scope={dirty:_,ctx:o}),cn.$set(wl);const vl={};_&2&&(vl.$$scope={dirty:_,ctx:o}),pn.$set(vl)},i(o){ld||(M(l.$$.fragment,o),M(I.$$.fragment,o),M(U.$$.fragment,o),M(Fn.$$.fragment,o),M(qn.$$.fragment,o),M(En.$$.fragment,o),M(On.$$.fragment,o),M(Un.$$.fragment,o),M(Qn.$$.fragment,o),M(Rn.$$.fragment,o),M(To.$$.fragment,o),M(Xn.$$.fragment,o),M(Yn.$$.fragment,o),M(Gn.$$.fragment,o),M(es.$$.fragment,o),M(ts.$$.fragment,o),M(xo.$$.fragment,o),M(os.$$.fragment,o),M(ss.$$.fragment,o),M(as.$$.fragment,o),M(ls.$$.fragment,o),M(cs.$$.fragment,o),M(qo.$$.fragment,o),M(ps.$$.fragment,o),M(us.$$.fragment,o),M(_s.$$.fragment,o),M(zo.$$.fragment,o),M(Co.$$.fragment,o),M(ys.$$.fragment,o),M(bs.$$.fragment,o),M(Ls.$$.fragment,o),M(Po.$$.fragment,o),M(Do.$$.fragment,o),M(Ts.$$.fragment,o),M(Ms.$$.fragment,o),M(zs.$$.fragment,o),M(Oo.$$.fragment,o),M(Io.$$.fragment,o),M(Cs.$$.fragment,o),M(As.$$.fragment,o),M(Us.$$.fragment,o),M(Uo.$$.fragment,o),M(Wo.$$.fragment,o),M(Ws.$$.fragment,o),M(Hs.$$.fragment,o),M(Xs.$$.fragment,o),M(Ko.$$.fragment,o),M(Ys.$$.fragment,o),M(Zs.$$.fragment,o),M(Qo.$$.fragment,o),M(ta.$$.fragment,o),M(Ro.$$.fragment,o),M(Vo.$$.fragment,o),M(oa.$$.fragment,o),M(na.$$.fragment,o),M(Yo.$$.fragment,o),M(la.$$.fragment,o),M(Zo.$$.fragment,o),M(Go.$$.fragment,o),M(da.$$.fragment,o),M(ca.$$.fragment,o),M(en.$$.fragment,o),M(ma.$$.fragment,o),M(tn.$$.fragment,o),M(on.$$.fragment,o),M(fa.$$.fragment,o),M(ga.$$.fragment,o),M(sn.$$.fragment,o),M(ka.$$.fragment,o),M(an.$$.fragment,o),M(rn.$$.fragment,o),M(wa.$$.fragment,o),M(va.$$.fragment,o),M(dn.$$.fragment,o),M(xa.$$.fragment,o),M(cn.$$.fragment,o),M(pn.$$.fragment,o),ld=!0)},o(o){$(l.$$.fragment,o),$(I.$$.fragment,o),$(U.$$.fragment,o),$(Fn.$$.fragment,o),$(qn.$$.fragment,o),$(En.$$.fragment,o),$(On.$$.fragment,o),$(Un.$$.fragment,o),$(Qn.$$.fragment,o),$(Rn.$$.fragment,o),$(To.$$.fragment,o),$(Xn.$$.fragment,o),$(Yn.$$.fragment,o),$(Gn.$$.fragment,o),$(es.$$.fragment,o),$(ts.$$.fragment,o),$(xo.$$.fragment,o),$(os.$$.fragment,o),$(ss.$$.fragment,o),$(as.$$.fragment,o),$(ls.$$.fragment,o),$(cs.$$.fragment,o),$(qo.$$.fragment,o),$(ps.$$.fragment,o),$(us.$$.fragment,o),$(_s.$$.fragment,o),$(zo.$$.fragment,o),$(Co.$$.fragment,o),$(ys.$$.fragment,o),$(bs.$$.fragment,o),$(Ls.$$.fragment,o),$(Po.$$.fragment,o),$(Do.$$.fragment,o),$(Ts.$$.fragment,o),$(Ms.$$.fragment,o),$(zs.$$.fragment,o),$(Oo.$$.fragment,o),$(Io.$$.fragment,o),$(Cs.$$.fragment,o),$(As.$$.fragment,o),$(Us.$$.fragment,o),$(Uo.$$.fragment,o),$(Wo.$$.fragment,o),$(Ws.$$.fragment,o),$(Hs.$$.fragment,o),$(Xs.$$.fragment,o),$(Ko.$$.fragment,o),$(Ys.$$.fragment,o),$(Zs.$$.fragment,o),$(Qo.$$.fragment,o),$(ta.$$.fragment,o),$(Ro.$$.fragment,o),$(Vo.$$.fragment,o),$(oa.$$.fragment,o),$(na.$$.fragment,o),$(Yo.$$.fragment,o),$(la.$$.fragment,o),$(Zo.$$.fragment,o),$(Go.$$.fragment,o),$(da.$$.fragment,o),$(ca.$$.fragment,o),$(en.$$.fragment,o),$(ma.$$.fragment,o),$(tn.$$.fragment,o),$(on.$$.fragment,o),$(fa.$$.fragment,o),$(ga.$$.fragment,o),$(sn.$$.fragment,o),$(ka.$$.fragment,o),$(an.$$.fragment,o),$(rn.$$.fragment,o),$(wa.$$.fragment,o),$(va.$$.fragment,o),$(dn.$$.fragment,o),$(xa.$$.fragment,o),$(cn.$$.fragment,o),$(pn.$$.fragment,o),ld=!1},d(o){t(d),o&&t(k),o&&t(f),x(l),o&&t(_e),o&&t(W),o&&t(ye),o&&t(B),x(I),o&&t(be),o&&t(se),o&&t(ke),o&&t(oe),o&&t(we),o&&t(H),o&&t(ve),o&&t(O),o&&t(Le),o&&t(ee),o&&t(Te),o&&t(D),o&&t(Oe),x(U,o),o&&t(Ie),o&&t(ge),o&&t(Ll),x(Fn,o),o&&t(Tl),o&&t(Ht),x(qn),o&&t(Ml),o&&t(Aa),o&&t($l),x(En,o),o&&t(xl),o&&t(_t),o&&t(jl),x(On,o),o&&t(Fl),o&&t(wo),o&&t(ql),x(Un,o),o&&t(El),o&&t(vo),o&&t(zl),o&&t(Ia),o&&t(Cl),o&&t(Sa),o&&t(Al),o&&t(Wa),o&&t(Pl),o&&t(Ha),o&&t(Dl),o&&t(Kt),x(Qn),o&&t(Nl),o&&t(ut),x(Rn),x(To),o&&t(Ol),o&&t(Rt),x(Xn),o&&t(Il),o&&t(Se),x(Yn),x(Gn),x(es),x(ts),x(xo),x(os),o&&t(Sl),o&&t(Xt),x(ss),o&&t(Ul),o&&t(nt),x(as),x(ls),x(cs),x(qo),o&&t(Wl),o&&t(Zt),x(ps),o&&t(Hl),o&&t(ht),x(us),x(_s),x(zo),x(Co),o&&t(Kl),o&&t(Jt),x(ys),o&&t(Bl),o&&t(mt),x(bs),x(Ls),x(Po),x(Do),o&&t(Ql),o&&t(oo),x(Ts),o&&t(Rl),o&&t(st),x(Ms),x(zs),x(Oo),x(Io),o&&t(Vl),o&&t(so),x(Cs),o&&t(Xl),o&&t(at),x(As),x(Us),x(Uo),x(Wo),o&&t(Yl),o&&t(io),x(Ws),o&&t(Zl),o&&t(rt),x(Hs),x(Xs),x(Ko),o&&t(Gl),o&&t(lo),x(Ys),o&&t(Jl),o&&t(Ze),x(Zs),x(Qo),x(ta),x(Ro),x(Vo),o&&t(ed),o&&t(po),x(oa),o&&t(td),o&&t(Ge),x(na),x(Yo),x(la),x(Zo),x(Go),o&&t(od),o&&t(ho),x(da),o&&t(nd),o&&t(Je),x(ca),x(en),x(ma),x(tn),x(on),o&&t(sd),o&&t(fo),x(fa),o&&t(ad),o&&t(et),x(ga),x(sn),x(ka),x(an),x(rn),o&&t(rd),o&&t(_o),x(wa),o&&t(id),o&&t(tt),x(va),x(dn),x(xa),x(cn),x(pn)}}}const kk={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 wk(z){return Bb(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fk extends Ub{constructor(d){super();Wb(this,d,wk,bk,Hb,{})}}export{Fk as default,kk as metadata};
