import{s as ca,o as pa,n as x}from"../chunks/scheduler.9bc65507.js";import{S as ua,i as ma,g as a,s as i,u as _,A as ha,h as r,f as t,c as l,j as g,v as b,y as m,k as h,o as n,a as c,w as M,d as v,t as y,x as T}from"../chunks/index.78c82d43.js";import{T as tn}from"../chunks/Tip.87d55b76.js";import{D as F}from"../chunks/Docstring.4e7352e2.js";import{C as We}from"../chunks/CodeBlock.73e038be.js";import{I as Y}from"../chunks/IconCopyLink.bedaa44d.js";import{E as bt}from"../chunks/ExampleCodeBlock.872b014d.js";function ga(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpc3VhbEJlcnRDb25maWclMkMlMjBWaXN1YWxCZXJ0TW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwVmlzdWFsQkVSVCUyMHZpc3VhbGJlcnQtdnFhLWNvY28tcHJlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFZpc3VhbEJlcnRDb25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMnVjbGFubHAlMkZ2aXN1YWxiZXJ0LXZxYS1jb2NvLXByZSUyMiklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjAod2l0aCUyMHJhbmRvbSUyMHdlaWdodHMpJTIwZnJvbSUyMHRoZSUyMHZpc3VhbGJlcnQtdnFhLWNvY28tcHJlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBWaXN1YWxCZXJ0TW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VisualBertConfig, VisualBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a VisualBERT visualbert-vqa-coco-pre style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = VisualBertConfig.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vqa-coco-pre&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the visualbert-vqa-coco-pre style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisualBertModel(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`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function fa(J){let o,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){o=a("p"),o.innerHTML=w},l(p){o=r(p,"P",{"data-svelte-h":!0}),m(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(p,u){c(p,o,u)},p:x,d(p){p&&t(o)}}}function _a(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"JTIzJTIwQXNzdW1wdGlvbiUzQSUyMCpnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpKiUyMGdldHMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwb2YlMjB0aGUlMjBpbWFnZS4lMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFZpc3VhbEJlcnRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXN1YWxCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnVjbGFubHAlMkZ2aXN1YWxiZXJ0LXZxYS1jb2NvLXByZSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyVGhlJTIwY2FwaXRhbCUyMG9mJTIwRnJhbmNlJTIwaXMlMjBQYXJpcy4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXZpc3VhbF9lbWJlZHMlMjAlM0QlMjBnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpLnVuc3F1ZWV6ZSgwKSUwQXZpc3VhbF90b2tlbl90eXBlX2lkcyUyMCUzRCUyMHRvcmNoLm9uZXModmlzdWFsX2VtYmVkcy5zaGFwZSU1QiUzQS0xJTVEJTJDJTIwZHR5cGUlM0R0b3JjaC5sb25nKSUwQXZpc3VhbF9hdHRlbnRpb25fbWFzayUyMCUzRCUyMHRvcmNoLm9uZXModmlzdWFsX2VtYmVkcy5zaGFwZSU1QiUzQS0xJTVEJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdCklMEElMEFpbnB1dHMudXBkYXRlKCUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnZpc3VhbF9lbWJlZHMlMjIlM0ElMjB2aXN1YWxfZW1iZWRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX3Rva2VuX3R5cGVfaWRzJTIyJTNBJTIwdmlzdWFsX3Rva2VuX3R5cGVfaWRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX2F0dGVudGlvbl9tYXNrJTIyJTNBJTIwdmlzdWFsX2F0dGVudGlvbl9tYXNrJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTBBKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-comment"># Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image.</span>
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, VisualBertModel
<span class="hljs-keyword">import</span> torch

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
model = VisualBertModel.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vqa-coco-pre&quot;</span>)

inputs = tokenizer(<span class="hljs-string">&quot;The capital of France is Paris.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
visual_embeds = get_visual_embeddings(image).unsqueeze(<span class="hljs-number">0</span>)
visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)

inputs.update(
    {
        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
    }
)

outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function ba(J){let o,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){o=a("p"),o.innerHTML=w},l(p){o=r(p,"P",{"data-svelte-h":!0}),m(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(p,u){c(p,o,u)},p:x,d(p){p&&t(o)}}}function Ma(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"JTIzJTIwQXNzdW1wdGlvbiUzQSUyMCpnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpKiUyMGdldHMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwb2YlMjB0aGUlMjBpbWFnZSUyMGluJTIwdGhlJTIwYmF0Y2guJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBWaXN1YWxCZXJ0Rm9yUHJlVHJhaW5pbmclMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMFZpc3VhbEJlcnRGb3JQcmVUcmFpbmluZy5mcm9tX3ByZXRyYWluZWQoJTIydWNsYW5scCUyRnZpc3VhbGJlcnQtdnFhLWNvY28tcHJlJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJUaGUlMjBjYXBpdGFsJTIwb2YlMjBGcmFuY2UlMjBpcyUyMCU1Qk1BU0slNUQuJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEF2aXN1YWxfZW1iZWRzJTIwJTNEJTIwZ2V0X3Zpc3VhbF9lbWJlZGRpbmdzKGltYWdlKS51bnNxdWVlemUoMCklMEF2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMjAlM0QlMjB0b3JjaC5vbmVzKHZpc3VhbF9lbWJlZHMuc2hhcGUlNUIlM0EtMSU1RCUyQyUyMGR0eXBlJTNEdG9yY2gubG9uZyklMEF2aXN1YWxfYXR0ZW50aW9uX21hc2slMjAlM0QlMjB0b3JjaC5vbmVzKHZpc3VhbF9lbWJlZHMuc2hhcGUlNUIlM0EtMSU1RCUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQpJTBBJTBBaW5wdXRzLnVwZGF0ZSglMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfZW1iZWRzJTIyJTNBJTIwdmlzdWFsX2VtYmVkcyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnZpc3VhbF90b2tlbl90eXBlX2lkcyUyMiUzQSUyMHZpc3VhbF90b2tlbl90eXBlX2lkcyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnZpc3VhbF9hdHRlbnRpb25fbWFzayUyMiUzQSUyMHZpc3VhbF9hdHRlbnRpb25fbWFzayUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSklMEFtYXhfbGVuZ3RoJTIwJTNEJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCLTElNUQlMjAlMkIlMjB2aXN1YWxfZW1iZWRzLnNoYXBlJTVCLTIlNUQlMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIyVGhlJTIwY2FwaXRhbCUyMG9mJTIwRnJhbmNlJTIwaXMlMjBQYXJpcy4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTIwcGFkZGluZyUzRCUyMm1heF9sZW5ndGglMjIlMkMlMjBtYXhfbGVuZ3RoJTNEbWF4X2xlbmd0aCUwQSklNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEFzZW50ZW5jZV9pbWFnZV9sYWJlbHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoMSkudW5zcXVlZXplKDApJTIwJTIwJTIzJTIwQmF0Y2hfc2l6ZSUwQSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscyUyQyUyMHNlbnRlbmNlX2ltYWdlX2xhYmVscyUzRHNlbnRlbmNlX2ltYWdlX2xhYmVscyklMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBcHJlZGljdGlvbl9sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLnByZWRpY3Rpb25fbG9naXRzJTBBc2VxX3JlbGF0aW9uc2hpcF9sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLnNlcV9yZWxhdGlvbnNoaXBfbG9naXRz",highlighted:`<span class="hljs-comment"># Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image in the batch.</span>
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, VisualBertForPreTraining

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
model = VisualBertForPreTraining.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vqa-coco-pre&quot;</span>)

inputs = tokenizer(<span class="hljs-string">&quot;The capital of France is [MASK].&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
visual_embeds = get_visual_embeddings(image).unsqueeze(<span class="hljs-number">0</span>)
visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)

inputs.update(
    {
        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
    }
)
max_length = inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[-<span class="hljs-number">1</span>] + visual_embeds.shape[-<span class="hljs-number">2</span>]
labels = tokenizer(
    <span class="hljs-string">&quot;The capital of France is Paris.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-string">&quot;max_length&quot;</span>, max_length=max_length
)[<span class="hljs-string">&quot;input_ids&quot;</span>]
sentence_image_labels = torch.tensor(<span class="hljs-number">1</span>).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch_size</span>


outputs = model(**inputs, labels=labels, sentence_image_labels=sentence_image_labels)
loss = outputs.loss
prediction_logits = outputs.prediction_logits
seq_relationship_logits = outputs.seq_relationship_logits`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function va(J){let o,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){o=a("p"),o.innerHTML=w},l(p){o=r(p,"P",{"data-svelte-h":!0}),m(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(p,u){c(p,o,u)},p:x,d(p){p&&t(o)}}}function ya(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"JTIzJTIwQXNzdW1wdGlvbiUzQSUyMCpnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpKiUyMGdldHMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwb2YlMjB0aGUlMjBpbWFnZSUyMGluJTIwdGhlJTIwYmF0Y2guJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBWaXN1YWxCZXJ0Rm9yUXVlc3Rpb25BbnN3ZXJpbmclMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQW1vZGVsJTIwJTNEJTIwVmlzdWFsQmVydEZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZCglMjJ1Y2xhbmxwJTJGdmlzdWFsYmVydC12cWElMjIpJTBBJTBBdGV4dCUyMCUzRCUyMCUyMldobyUyMGlzJTIwZWF0aW5nJTIwdGhlJTIwYXBwbGUlM0YlMjIlMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBdmlzdWFsX2VtYmVkcyUyMCUzRCUyMGdldF92aXN1YWxfZW1iZWRkaW5ncyhpbWFnZSkudW5zcXVlZXplKDApJTBBdmlzdWFsX3Rva2VuX3R5cGVfaWRzJTIwJTNEJTIwdG9yY2gub25lcyh2aXN1YWxfZW1iZWRzLnNoYXBlJTVCJTNBLTElNUQlMkMlMjBkdHlwZSUzRHRvcmNoLmxvbmcpJTBBdmlzdWFsX2F0dGVudGlvbl9tYXNrJTIwJTNEJTIwdG9yY2gub25lcyh2aXN1YWxfZW1iZWRzLnNoYXBlJTVCJTNBLTElNUQlMkMlMjBkdHlwZSUzRHRvcmNoLmZsb2F0KSUwQSUwQWlucHV0cy51cGRhdGUoJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX2VtYmVkcyUyMiUzQSUyMHZpc3VhbF9lbWJlZHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMjIlM0ElMjB2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfYXR0ZW50aW9uX21hc2slMjIlM0ElMjB2aXN1YWxfYXR0ZW50aW9uX21hc2slMkMlMEElMjAlMjAlMjAlMjAlN0QlMEEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QiU1QjAuMCUyQyUyMDEuMCU1RCU1RCkudW5zcXVlZXplKDApJTIwJTIwJTIzJTIwQmF0Y2glMjBzaXplJTIwMSUyQyUyME51bSUyMGxhYmVscyUyMDIlMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXNjb3JlcyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-comment"># Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image in the batch.</span>
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, VisualBertForQuestionAnswering
<span class="hljs-keyword">import</span> torch

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
model = VisualBertForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vqa&quot;</span>)

text = <span class="hljs-string">&quot;Who is eating the apple?&quot;</span>
inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
visual_embeds = get_visual_embeddings(image).unsqueeze(<span class="hljs-number">0</span>)
visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)

inputs.update(
    {
        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
    }
)

labels = torch.tensor([[<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>]]).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size 1, Num labels 2</span>

outputs = model(**inputs, labels=labels)
loss = outputs.loss
scores = outputs.logits`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function Ta(J){let o,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){o=a("p"),o.innerHTML=w},l(p){o=r(p,"P",{"data-svelte-h":!0}),m(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(p,u){c(p,o,u)},p:x,d(p){p&&t(o)}}}function wa(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"JTIzJTIwQXNzdW1wdGlvbiUzQSUyMCpnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpKiUyMGdldHMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwb2YlMjB0aGUlMjBpbWFnZSUyMGluJTIwdGhlJTIwYmF0Y2guJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBWaXN1YWxCZXJ0Rm9yTXVsdGlwbGVDaG9pY2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQW1vZGVsJTIwJTNEJTIwVmlzdWFsQmVydEZvck11bHRpcGxlQ2hvaWNlLmZyb21fcHJldHJhaW5lZCglMjJ1Y2xhbmxwJTJGdmlzdWFsYmVydC12Y3IlMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIySW4lMjBJdGFseSUyQyUyMHBpenphJTIwc2VydmVkJTIwaW4lMjBmb3JtYWwlMjBzZXR0aW5ncyUyQyUyMHN1Y2glMjBhcyUyMGF0JTIwYSUyMHJlc3RhdXJhbnQlMkMlMjBpcyUyMHByZXNlbnRlZCUyMHVuc2xpY2VkLiUyMiUwQWNob2ljZTAlMjAlM0QlMjAlMjJJdCUyMGlzJTIwZWF0ZW4lMjB3aXRoJTIwYSUyMGZvcmslMjBhbmQlMjBhJTIwa25pZmUuJTIyJTBBY2hvaWNlMSUyMCUzRCUyMCUyMkl0JTIwaXMlMjBlYXRlbiUyMHdoaWxlJTIwaGVsZCUyMGluJTIwdGhlJTIwaGFuZC4lMjIlMEElMEF2aXN1YWxfZW1iZWRzJTIwJTNEJTIwZ2V0X3Zpc3VhbF9lbWJlZGRpbmdzKGltYWdlKSUwQSUyMyUyMChiYXRjaF9zaXplJTJDJTIwbnVtX2Nob2ljZXMlMkMlMjB2aXN1YWxfc2VxX2xlbmd0aCUyQyUyMHZpc3VhbF9lbWJlZGRpbmdfZGltKSUwQXZpc3VhbF9lbWJlZHMlMjAlM0QlMjB2aXN1YWxfZW1iZWRzLmV4cGFuZCgxJTJDJTIwMiUyQyUyMCp2aXN1YWxfZW1iZWRzLnNoYXBlKSUwQXZpc3VhbF90b2tlbl90eXBlX2lkcyUyMCUzRCUyMHRvcmNoLm9uZXModmlzdWFsX2VtYmVkcy5zaGFwZSU1QiUzQS0xJTVEJTJDJTIwZHR5cGUlM0R0b3JjaC5sb25nKSUwQXZpc3VhbF9hdHRlbnRpb25fbWFzayUyMCUzRCUyMHRvcmNoLm9uZXModmlzdWFsX2VtYmVkcy5zaGFwZSU1QiUzQS0xJTVEJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdCklMEElMEFsYWJlbHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoMCkudW5zcXVlZXplKDApJTIwJTIwJTIzJTIwY2hvaWNlMCUyMGlzJTIwY29ycmVjdCUyMChhY2NvcmRpbmclMjB0byUyMFdpa2lwZWRpYSUyMCUzQikpJTJDJTIwYmF0Y2glMjBzaXplJTIwMSUwQSUwQWVuY29kaW5nJTIwJTNEJTIwdG9rZW5pemVyKCU1QiU1QnByb21wdCUyQyUyMHByb21wdCU1RCUyQyUyMCU1QmNob2ljZTAlMkMlMjBjaG9pY2UxJTVEJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQSUyMyUyMGJhdGNoJTIwc2l6ZSUyMGlzJTIwMSUwQWlucHV0c19kaWN0JTIwJTNEJTIwJTdCayUzQSUyMHYudW5zcXVlZXplKDApJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGVuY29kaW5nLml0ZW1zKCklN0QlMEFpbnB1dHNfZGljdC51cGRhdGUoJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX2VtYmVkcyUyMiUzQSUyMHZpc3VhbF9lbWJlZHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfYXR0ZW50aW9uX21hc2slMjIlM0ElMjB2aXN1YWxfYXR0ZW50aW9uX21hc2slMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMjIlM0ElMjB2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsYWJlbHMlMjIlM0ElMjBsYWJlbHMlMkMlMEElMjAlMjAlMjAlMjAlN0QlMEEpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzX2RpY3QpJTBBJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQWxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-comment"># Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image in the batch.</span>
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, VisualBertForMultipleChoice
<span class="hljs-keyword">import</span> torch

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
model = VisualBertForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vcr&quot;</span>)

prompt = <span class="hljs-string">&quot;In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced.&quot;</span>
choice0 = <span class="hljs-string">&quot;It is eaten with a fork and a knife.&quot;</span>
choice1 = <span class="hljs-string">&quot;It is eaten while held in the hand.&quot;</span>

visual_embeds = get_visual_embeddings(image)
<span class="hljs-comment"># (batch_size, num_choices, visual_seq_length, visual_embedding_dim)</span>
visual_embeds = visual_embeds.expand(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, *visual_embeds.shape)
visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)

labels = torch.tensor(<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># choice0 is correct (according to Wikipedia ;)), batch size 1</span>

encoding = tokenizer([[prompt, prompt], [choice0, choice1]], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-comment"># batch size is 1</span>
inputs_dict = {k: v.unsqueeze(<span class="hljs-number">0</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> encoding.items()}
inputs_dict.update(
    {
        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
        <span class="hljs-string">&quot;labels&quot;</span>: labels,
    }
)
outputs = model(**inputs_dict)

loss = outputs.loss
logits = outputs.logits`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function ka(J){let o,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){o=a("p"),o.innerHTML=w},l(p){o=r(p,"P",{"data-svelte-h":!0}),m(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(p,u){c(p,o,u)},p:x,d(p){p&&t(o)}}}function Ja(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"JTIzJTIwQXNzdW1wdGlvbiUzQSUyMCpnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpKiUyMGdldHMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwb2YlMjB0aGUlMjBpbWFnZSUyMGluJTIwdGhlJTIwYmF0Y2guJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBWaXN1YWxCZXJ0Rm9yVmlzdWFsUmVhc29uaW5nJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMFZpc3VhbEJlcnRGb3JWaXN1YWxSZWFzb25pbmcuZnJvbV9wcmV0cmFpbmVkKCUyMnVjbGFubHAlMkZ2aXN1YWxiZXJ0LW5sdnIyJTIyKSUwQSUwQXRleHQlMjAlM0QlMjAlMjJXaG8lMjBpcyUyMGVhdGluZyUyMHRoZSUyMGFwcGxlJTNGJTIyJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXZpc3VhbF9lbWJlZHMlMjAlM0QlMjBnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpLnVuc3F1ZWV6ZSgwKSUwQXZpc3VhbF90b2tlbl90eXBlX2lkcyUyMCUzRCUyMHRvcmNoLm9uZXModmlzdWFsX2VtYmVkcy5zaGFwZSU1QiUzQS0xJTVEJTJDJTIwZHR5cGUlM0R0b3JjaC5sb25nKSUwQXZpc3VhbF9hdHRlbnRpb25fbWFzayUyMCUzRCUyMHRvcmNoLm9uZXModmlzdWFsX2VtYmVkcy5zaGFwZSU1QiUzQS0xJTVEJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdCklMEElMEFpbnB1dHMudXBkYXRlKCUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnZpc3VhbF9lbWJlZHMlMjIlM0ElMjB2aXN1YWxfZW1iZWRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX3Rva2VuX3R5cGVfaWRzJTIyJTNBJTIwdmlzdWFsX3Rva2VuX3R5cGVfaWRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX2F0dGVudGlvbl9tYXNrJTIyJTNBJTIwdmlzdWFsX2F0dGVudGlvbl9tYXNrJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTBBKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvcigxKS51bnNxdWVlemUoMCklMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlMjAxJTJDJTIwTnVtJTIwY2hvaWNlcyUyMDIlMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXNjb3JlcyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-comment"># Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image in the batch.</span>
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, VisualBertForVisualReasoning
<span class="hljs-keyword">import</span> torch

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
model = VisualBertForVisualReasoning.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-nlvr2&quot;</span>)

text = <span class="hljs-string">&quot;Who is eating the apple?&quot;</span>
inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
visual_embeds = get_visual_embeddings(image).unsqueeze(<span class="hljs-number">0</span>)
visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)

inputs.update(
    {
        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
    }
)

labels = torch.tensor(<span class="hljs-number">1</span>).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size 1, Num choices 2</span>

outputs = model(**inputs, labels=labels)
loss = outputs.loss
scores = outputs.logits`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function Va(J){let o,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){o=a("p"),o.innerHTML=w},l(p){o=r(p,"P",{"data-svelte-h":!0}),m(o)!=="svelte-fincs2"&&(o.innerHTML=w)},m(p,u){c(p,o,u)},p:x,d(p){p&&t(o)}}}function Ba(J){let o,w="Example:",p,u,f;return u=new We({props:{code:"JTIzJTIwQXNzdW1wdGlvbiUzQSUyMCpnZXRfdmlzdWFsX2VtYmVkZGluZ3MoaW1hZ2UpKiUyMGdldHMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwb2YlMjB0aGUlMjBpbWFnZSUyMGluJTIwdGhlJTIwYmF0Y2guJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBWaXN1YWxCZXJ0Rm9yUmVnaW9uVG9QaHJhc2VBbGlnbm1lbnQlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQW1vZGVsJTIwJTNEJTIwVmlzdWFsQmVydEZvclJlZ2lvblRvUGhyYXNlQWxpZ25tZW50LmZyb21fcHJldHJhaW5lZCglMjJ1Y2xhbmxwJTJGdmlzdWFsYmVydC12cWEtY29jby1wcmUlMjIpJTBBJTBBdGV4dCUyMCUzRCUyMCUyMldobyUyMGlzJTIwZWF0aW5nJTIwdGhlJTIwYXBwbGUlM0YlMjIlMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBdmlzdWFsX2VtYmVkcyUyMCUzRCUyMGdldF92aXN1YWxfZW1iZWRkaW5ncyhpbWFnZSkudW5zcXVlZXplKDApJTBBdmlzdWFsX3Rva2VuX3R5cGVfaWRzJTIwJTNEJTIwdG9yY2gub25lcyh2aXN1YWxfZW1iZWRzLnNoYXBlJTVCJTNBLTElNUQlMkMlMjBkdHlwZSUzRHRvcmNoLmxvbmcpJTBBdmlzdWFsX2F0dGVudGlvbl9tYXNrJTIwJTNEJTIwdG9yY2gub25lcyh2aXN1YWxfZW1iZWRzLnNoYXBlJTVCJTNBLTElNUQlMkMlMjBkdHlwZSUzRHRvcmNoLmZsb2F0KSUwQXJlZ2lvbl90b19waHJhc2VfcG9zaXRpb24lMjAlM0QlMjB0b3JjaC5vbmVzKCgxJTJDJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCLTElNUQlMjAlMkIlMjB2aXN1YWxfZW1iZWRzLnNoYXBlJTVCLTIlNUQpKSUwQSUwQWlucHV0cy51cGRhdGUoJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycmVnaW9uX3RvX3BocmFzZV9wb3NpdGlvbiUyMiUzQSUyMHJlZ2lvbl90b19waHJhc2VfcG9zaXRpb24lMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfZW1iZWRzJTIyJTNBJTIwdmlzdWFsX2VtYmVkcyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnZpc3VhbF90b2tlbl90eXBlX2lkcyUyMiUzQSUyMHZpc3VhbF90b2tlbl90eXBlX2lkcyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnZpc3VhbF9hdHRlbnRpb25fbWFzayUyMiUzQSUyMHZpc3VhbF9hdHRlbnRpb25fbWFzayUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSklMEElMEFsYWJlbHMlMjAlM0QlMjB0b3JjaC5vbmVzKCUwQSUyMCUyMCUyMCUyMCgxJTJDJTIwaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlJTVCLTElNUQlMjAlMkIlMjB2aXN1YWxfZW1iZWRzLnNoYXBlJTVCLTIlNUQlMkMlMjB2aXN1YWxfZW1iZWRzLnNoYXBlJTVCLTIlNUQpJTBBKSUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXNjb3JlcyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-comment"># Assumption: *get_visual_embeddings(image)* gets the visual embeddings of the image in the batch.</span>
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, VisualBertForRegionToPhraseAlignment
<span class="hljs-keyword">import</span> torch

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
model = VisualBertForRegionToPhraseAlignment.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vqa-coco-pre&quot;</span>)

text = <span class="hljs-string">&quot;Who is eating the apple?&quot;</span>
inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
visual_embeds = get_visual_embeddings(image).unsqueeze(<span class="hljs-number">0</span>)
visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)
region_to_phrase_position = torch.ones((<span class="hljs-number">1</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[-<span class="hljs-number">1</span>] + visual_embeds.shape[-<span class="hljs-number">2</span>]))

inputs.update(
    {
        <span class="hljs-string">&quot;region_to_phrase_position&quot;</span>: region_to_phrase_position,
        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
    }
)

labels = torch.ones(
    (<span class="hljs-number">1</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[-<span class="hljs-number">1</span>] + visual_embeds.shape[-<span class="hljs-number">2</span>], visual_embeds.shape[-<span class="hljs-number">2</span>])
)  <span class="hljs-comment"># Batch size 1</span>

outputs = model(**inputs, labels=labels)
loss = outputs.loss
scores = outputs.logits`,wrap:!1}}),{c(){o=a("p"),o.textContent=w,p=i(),_(u.$$.fragment)},l(s){o=r(s,"P",{"data-svelte-h":!0}),m(o)!=="svelte-11lpom8"&&(o.textContent=w),p=l(s),b(u.$$.fragment,s)},m(s,k){c(s,o,k),c(s,p,k),M(u,s,k),f=!0},p:x,i(s){f||(v(u.$$.fragment,s),f=!0)},o(s){y(u.$$.fragment,s),f=!1},d(s){s&&(t(o),t(p)),T(u,s)}}}function Ua(J){let o,w,p,u,f,s,k,Fe,oo,Mt,as="VisualBERT",yn,S,se,nn,xe,so,vt,rs="Overview",Tn,Ie,is=`The VisualBERT model was proposed in <a href="https://arxiv.org/pdf/1908.03557" rel="nofollow">VisualBERT: A Simple and Performant Baseline for Vision and Language</a> by Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, Kai-Wei Chang.
VisualBERT is a neural network trained on a variety of (image, text) pairs.`,wn,$e,ls="The abstract from the paper is the following:",kn,Ze,ds=`<em>We propose VisualBERT, a simple and flexible framework for modeling a broad range of vision-and-language tasks.
VisualBERT consists of a stack of Transformer layers that implicitly align elements of an input text and regions in an
associated input image with self-attention. We further propose two visually-grounded language model objectives for
pre-training VisualBERT on image caption data. Experiments on four vision-and-language tasks including VQA, VCR, NLVR2,
and Flickr30K show that VisualBERT outperforms or rivals with state-of-the-art models while being significantly
simpler. Further analysis demonstrates that VisualBERT can ground elements of language to image regions without any
explicit supervision and is even sensitive to syntactic relationships, tracking, for example, associations between
verbs and image regions corresponding to their arguments.</em>`,Jn,Re,cs="Tips:",Vn,Xe,ps=`<li><p>Most of the checkpoints provided work with the <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertForPreTraining">VisualBertForPreTraining</a> configuration. Other
checkpoints provided are the fine-tuned checkpoints for down-stream tasks - VQA (‘visualbert-vqa’), VCR
(‘visualbert-vcr’), NLVR2 (‘visualbert-nlvr2’). Hence, if you are not working on these downstream tasks, it is
recommended that you use the pretrained checkpoints.</p></li> <li><p>For the VCR task, the authors use a fine-tuned detector for generating visual embeddings, for all the checkpoints.
We do not provide the detector and its weights as a part of the package, but it will be available in the research
projects, and the states can be loaded directly into the detector provided.</p></li>`,Bn,P,ae,on,Ne,ao,yt,us="Usage",Un,Ge,ms=`VisualBERT is a multi-modal vision and language model. It can be used for visual question answering, multiple choice,
visual reasoning and region-to-phrase correspondence tasks. VisualBERT uses a BERT-like transformer to prepare
embeddings for image-text pairs. Both the text and visual features are then projected to a latent space with identical
dimension.`,jn,Ae,hs=`To feed images to the model, each image is passed through a pre-trained object detector and the regions and the
bounding boxes are extracted. The authors use the features generated after passing these regions through a pre-trained
CNN like ResNet as visual embeddings. They also add absolute position embeddings, and feed the resulting sequence of
vectors to a standard BERT model. The text input is concatenated in the front of the visual embeddings in the embedding
layer, and is expected to be bound by [CLS] and a [SEP] tokens, as in BERT. The segment IDs must also be set
appropriately for the textual and visual parts.`,Cn,He,gs=`The <a href="/docs/transformers/v4.34.0/en/model_doc/bert#transformers.BertTokenizer">BertTokenizer</a> is used to encode the text. A custom detector/image processor must be used
to get the visual embeddings. The following example notebooks show how to use VisualBERT with Detectron-like models:`,zn,qe,fs=`<li><p><a href="https://github.com/huggingface/transformers/tree/main/examples/research_projects/visual_bert" rel="nofollow">VisualBERT VQA demo notebook</a> : This notebook
contains an example on VisualBERT VQA.</p></li> <li><p><a href="https://colab.research.google.com/drive/1bLGxKdldwqnMVA5x4neY7-l_8fKGWQYI?usp=sharing" rel="nofollow">Generate Embeddings for VisualBERT (Colab Notebook)</a> : This notebook contains
an example on how to generate visual embeddings.</p></li>`,Wn,Ee,_s='The following example shows how to get the last hidden state using <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertModel">VisualBertModel</a>:',Fn,Le,xn,Qe,bs='This model was contributed by <a href="https://huggingface.co/gchhablani" rel="nofollow">gchhablani</a>. The original code can be found <a href="https://github.com/uclanlp/visualbert" rel="nofollow">here</a>.',In,O,re,sn,Ye,ro,Tt,Ms="VisualBertConfig",$n,W,Se,io,wt,vs=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertModel">VisualBertModel</a>. It is used to instantiate an
VisualBERT 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 VisualBERT
<a href="https://huggingface.co/uclanlp/visualbert-vqa-coco-pre" rel="nofollow">uclanlp/visualbert-vqa-coco-pre</a> architecture.`,lo,kt,ys=`Configuration objects inherit from <a href="/docs/transformers/v4.34.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/v4.34.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,co,ie,Zn,D,le,an,Pe,po,Jt,Ts="VisualBertModel",Rn,V,Oe,uo,Vt,ws=`The bare VisualBert Model transformer outputting raw hidden-states without any specific head on top.
This model inherits from <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,mo,Bt,ks=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,ho,Ut,Js=`The model can behave as an encoder (with only self-attention) following the architecture described in <a href="https://arxiv.org/abs/1706.03762" rel="nofollow">Attention is
all you need</a> by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`,go,I,De,fo,jt,Vs='The <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertModel">VisualBertModel</a> forward method, overrides the <code>__call__</code> special method.',_o,de,bo,ce,Xn,K,pe,rn,Ke,Mo,Ct,Bs="VisualBertForPreTraining",Nn,B,et,vo,zt,Us=`VisualBert Model with two heads on top as done during the pretraining: a <code>masked language modeling</code> head and a
<code>sentence-image prediction (classification)</code> head.`,yo,Wt,js=`This model inherits from <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,To,Ft,Cs=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,wo,$,tt,ko,xt,zs='The <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertForPreTraining">VisualBertForPreTraining</a> forward method, overrides the <code>__call__</code> special method.',Jo,ue,Vo,me,Gn,ee,he,ln,nt,Bo,It,Ws="VisualBertForQuestionAnswering",An,U,ot,Uo,$t,Fs=`VisualBert Model with a classification/regression head on top (a dropout and a linear layer on top of the pooled
output) for VQA.`,jo,Zt,xs=`This model inherits from <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Co,Rt,Is=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,zo,Z,st,Wo,Xt,$s='The <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertForQuestionAnswering">VisualBertForQuestionAnswering</a> forward method, overrides the <code>__call__</code> special method.',Fo,ge,xo,fe,Hn,te,_e,dn,at,Io,Nt,Zs="VisualBertForMultipleChoice",qn,j,rt,$o,Gt,Rs=`VisualBert Model with a multiple choice classification head on top (a linear layer on top of the pooled output and
a softmax) e.g. for VCR tasks.`,Zo,At,Xs=`This model inherits from <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Ro,Ht,Ns=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,Xo,R,it,No,qt,Gs='The <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertForMultipleChoice">VisualBertForMultipleChoice</a> forward method, overrides the <code>__call__</code> special method.',Go,be,Ao,Me,En,ne,ve,cn,lt,Ho,Et,As="VisualBertForVisualReasoning",Ln,C,dt,qo,Lt,Hs=`VisualBert Model with a sequence classification head on top (a dropout and a linear layer on top of the pooled
output) for Visual Reasoning e.g. for NLVR task.`,Eo,Qt,qs=`This model inherits from <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Lo,Yt,Es=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,Qo,X,ct,Yo,St,Ls='The <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertForVisualReasoning">VisualBertForVisualReasoning</a> forward method, overrides the <code>__call__</code> special method.',So,ye,Po,Te,Qn,oe,we,pn,pt,Oo,Pt,Qs="VisualBertForRegionToPhraseAlignment",Yn,z,ut,Do,Ot,Ys=`VisualBert Model with a Masked Language Modeling head and an attention layer on top for Region-to-Phrase Alignment
e.g. for Flickr30 Entities task.`,Ko,Dt,Ss=`This model inherits from <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,es,Kt,Ps=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,ts,N,mt,ns,en,Os='The <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertForRegionToPhraseAlignment">VisualBertForRegionToPhraseAlignment</a> forward method, overrides the <code>__call__</code> special method.',os,ke,ss,Je,Sn,un,Pn;return Fe=new Y({}),xe=new Y({}),Ne=new Y({}),Le=new We({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQmVydFRva2VuaXplciUyQyUyMFZpc3VhbEJlcnRNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwVmlzdWFsQmVydE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJ1Y2xhbmxwJTJGdmlzdWFsYmVydC12cWEtY29jby1wcmUlMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMldoYXQlMjBpcyUyMHRoZSUyMG1hbiUyMGVhdGluZyUzRiUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTIzJTIwdGhpcyUyMGlzJTIwYSUyMGN1c3RvbSUyMGZ1bmN0aW9uJTIwdGhhdCUyMHJldHVybnMlMjB0aGUlMjB2aXN1YWwlMjBlbWJlZGRpbmdzJTIwZ2l2ZW4lMjB0aGUlMjBpbWFnZSUyMHBhdGglMEF2aXN1YWxfZW1iZWRzJTIwJTNEJTIwZ2V0X3Zpc3VhbF9lbWJlZGRpbmdzKGltYWdlX3BhdGgpJTBBJTBBdmlzdWFsX3Rva2VuX3R5cGVfaWRzJTIwJTNEJTIwdG9yY2gub25lcyh2aXN1YWxfZW1iZWRzLnNoYXBlJTVCJTNBLTElNUQlMkMlMjBkdHlwZSUzRHRvcmNoLmxvbmcpJTBBdmlzdWFsX2F0dGVudGlvbl9tYXNrJTIwJTNEJTIwdG9yY2gub25lcyh2aXN1YWxfZW1iZWRzLnNoYXBlJTVCJTNBLTElNUQlMkMlMjBkdHlwZSUzRHRvcmNoLmZsb2F0KSUwQWlucHV0cy51cGRhdGUoJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydmlzdWFsX2VtYmVkcyUyMiUzQSUyMHZpc3VhbF9lbWJlZHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMjIlM0ElMjB2aXN1YWxfdG9rZW5fdHlwZV9pZHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ2aXN1YWxfYXR0ZW50aW9uX21hc2slMjIlM0ElMjB2aXN1YWxfYXR0ZW50aW9uX21hc2slMkMlMEElMjAlMjAlMjAlMjAlN0QlMEEpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQWxhc3RfaGlkZGVuX3N0YXRlJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, VisualBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisualBertModel.from_pretrained(<span class="hljs-string">&quot;uclanlp/visualbert-vqa-coco-pre&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;What is the man eating?&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># this is a custom function that returns the visual embeddings given the image path</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>visual_embeds = get_visual_embeddings(image_path)

<span class="hljs-meta">&gt;&gt;&gt; </span>visual_token_type_ids = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.long)
<span class="hljs-meta">&gt;&gt;&gt; </span>visual_attention_mask = torch.ones(visual_embeds.shape[:-<span class="hljs-number">1</span>], dtype=torch.<span class="hljs-built_in">float</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs.update(
<span class="hljs-meta">... </span>    {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;visual_embeds&quot;</span>: visual_embeds,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;visual_token_type_ids&quot;</span>: visual_token_type_ids,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;visual_attention_mask&quot;</span>: visual_attention_mask,
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_state = outputs.last_hidden_state`,wrap:!1}}),Ye=new Y({}),Se=new F({props:{name:"class transformers.VisualBertConfig",anchor:"transformers.VisualBertConfig",parameters:[{name:"vocab_size",val:" = 30522"},{name:"hidden_size",val:" = 768"},{name:"visual_embedding_dim",val:" = 512"},{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:"bypass_transformer",val:" = False"},{name:"special_visual_initialize",val:" = True"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VisualBertConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 30522) &#x2014;
Vocabulary size of the VisualBERT model. Defines the number of different tokens that can be represented by
the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertModel">VisualBertModel</a>. Vocabulary size of the model. Defines the
different tokens that can be represented by the <code>inputs_ids</code> passed to the forward method of
<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertModel">VisualBertModel</a>.`,name:"vocab_size"},{anchor:"transformers.VisualBertConfig.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.VisualBertConfig.visual_embedding_dim",description:`<strong>visual_embedding_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
Dimensionality of the visual embeddings to be passed to the model.`,name:"visual_embedding_dim"},{anchor:"transformers.VisualBertConfig.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.VisualBertConfig.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.VisualBertConfig.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.VisualBertConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.VisualBertConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.VisualBertConfig.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.VisualBertConfig.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.VisualBertConfig.type_vocab_size",description:`<strong>type_vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The vocabulary size of the <code>token_type_ids</code> passed when calling <a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertModel">VisualBertModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.VisualBertConfig.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.VisualBertConfig.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.VisualBertConfig.bypass_transformer",description:`<strong>bypass_transformer</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not the model should bypass the transformer for the visual embeddings. If set to <code>True</code>, the
model directly concatenates the visual embeddings from <code>VisualBertEmbeddings</code> with text output from
transformers, and then pass it to a self-attention layer.`,name:"bypass_transformer"},{anchor:"transformers.VisualBertConfig.special_visual_initialize",description:`<strong>special_visual_initialize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the visual token type and position type embedding weights should be initialized the same as
the textual token type and positive type embeddings. When set to <code>True</code>, the weights of the textual token
type and position type embeddings are copied to the respective visual embedding layers.`,name:"special_visual_initialize"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/visual_bert/configuration_visual_bert.py#L43"}}),ie=new bt({props:{anchor:"transformers.VisualBertConfig.example",$$slots:{default:[ga]},$$scope:{ctx:J}}}),Pe=new Y({}),Oe=new F({props:{name:"class transformers.VisualBertModel",anchor:"transformers.VisualBertModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.VisualBertModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig">VisualBertConfig</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.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L678"}}),De=new F({props:{name:"forward",anchor:"transformers.VisualBertModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = 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.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"visual_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_text_alignment",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.VisualBertModel.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.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.VisualBertModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.VisualBertModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.VisualBertModel.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.VisualBertModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VisualBertModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.VisualBertModel.forward.visual_embeds",description:`<strong>visual_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length, visual_embedding_dim)</code>, <em>optional</em>) &#x2014;
The embedded representation of the visual inputs, generally derived using using an object detector.`,name:"visual_embeds"},{anchor:"transformers.VisualBertModel.forward.visual_attention_mask",description:`<strong>visual_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on visual embeddings. 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:"visual_attention_mask"},{anchor:"transformers.VisualBertModel.forward.visual_token_type_ids",description:`<strong>visual_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate different portions of the visual embeds.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a> The authors of VisualBERT set the
<em>visual_token_type_ids</em> to <em>1</em> for all tokens.`,name:"visual_token_type_ids"},{anchor:"transformers.VisualBertModel.forward.image_text_alignment",description:`<strong>image_text_alignment</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length, alignment_number)</code>, <em>optional</em>) &#x2014;
Image-Text alignment uses to decide the position IDs of the visual embeddings.`,name:"image_text_alignment"},{anchor:"transformers.VisualBertModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.VisualBertModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.VisualBertModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L717",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig"
>VisualBertConfig</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>) — 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>) — 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>) — 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>) — 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.34.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),de=new tn({props:{$$slots:{default:[fa]},$$scope:{ctx:J}}}),ce=new bt({props:{anchor:"transformers.VisualBertModel.forward.example",$$slots:{default:[_a]},$$scope:{ctx:J}}}),Ke=new Y({}),et=new F({props:{name:"class transformers.VisualBertForPreTraining",anchor:"transformers.VisualBertForPreTraining",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VisualBertForPreTraining.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig">VisualBertConfig</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.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L875"}}),tt=new F({props:{name:"forward",anchor:"transformers.VisualBertForPreTraining.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = 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.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"visual_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_text_alignment",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"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"sentence_image_labels",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.VisualBertForPreTraining.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.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.VisualBertForPreTraining.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.VisualBertForPreTraining.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.VisualBertForPreTraining.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.VisualBertForPreTraining.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VisualBertForPreTraining.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.VisualBertForPreTraining.forward.visual_embeds",description:`<strong>visual_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length, visual_embedding_dim)</code>, <em>optional</em>) &#x2014;
The embedded representation of the visual inputs, generally derived using using an object detector.`,name:"visual_embeds"},{anchor:"transformers.VisualBertForPreTraining.forward.visual_attention_mask",description:`<strong>visual_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on visual embeddings. 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:"visual_attention_mask"},{anchor:"transformers.VisualBertForPreTraining.forward.visual_token_type_ids",description:`<strong>visual_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate different portions of the visual embeds.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a> The authors of VisualBERT set the
<em>visual_token_type_ids</em> to <em>1</em> for all tokens.`,name:"visual_token_type_ids"},{anchor:"transformers.VisualBertForPreTraining.forward.image_text_alignment",description:`<strong>image_text_alignment</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length, alignment_number)</code>, <em>optional</em>) &#x2014;
Image-Text alignment uses to decide the position IDs of the visual embeddings.`,name:"image_text_alignment"},{anchor:"transformers.VisualBertForPreTraining.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.VisualBertForPreTraining.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.VisualBertForPreTraining.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VisualBertForPreTraining.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, total_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"},{anchor:"transformers.VisualBertForPreTraining.forward.sentence_image_labels",description:`<strong>sentence_image_labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sentence-image prediction (classification) loss. Input should be a sequence pair
(see <code>input_ids</code> docstring) Indices should be in <code>[0, 1]</code>:</p>
<ul>
<li>0 indicates sequence B is a matching pair of sequence A for the given image,</li>
<li>1 indicates sequence B is a random sequence w.r.t A for the given image.</li>
</ul>`,name:"sentence_image_labels"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L893",returnDescription:`
<p>A <code>transformers.models.visual_bert.modeling_visual_bert.VisualBertForPreTrainingOutput</code> 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.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig"
>VisualBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<em>optional</em>, returned when <code>labels</code> is provided, <code>torch.FloatTensor</code> of shape <code>(1,)</code>) — Total loss as the sum of the masked language modeling loss and the sentence-image prediction
(classification) loss.</p>
</li>
<li>
<p><strong>prediction_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>seq_relationship_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, 2)</code>) — Prediction scores of the sentence-image prediction (classification) head (scores of True/False continuation
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>) — Tuple of <code>torch.FloatTensor</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(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — 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><code>transformers.models.visual_bert.modeling_visual_bert.VisualBertForPreTrainingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ue=new tn({props:{$$slots:{default:[ba]},$$scope:{ctx:J}}}),me=new bt({props:{anchor:"transformers.VisualBertForPreTraining.forward.example",$$slots:{default:[Ma]},$$scope:{ctx:J}}}),nt=new Y({}),ot=new F({props:{name:"class transformers.VisualBertForQuestionAnswering",anchor:"transformers.VisualBertForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VisualBertForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig">VisualBertConfig</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.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1179"}}),st=new F({props:{name:"forward",anchor:"transformers.VisualBertForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = 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.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"visual_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_text_alignment",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"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.VisualBertForQuestionAnswering.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.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.VisualBertForQuestionAnswering.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.VisualBertForQuestionAnswering.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.VisualBertForQuestionAnswering.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.visual_embeds",description:`<strong>visual_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length, visual_embedding_dim)</code>, <em>optional</em>) &#x2014;
The embedded representation of the visual inputs, generally derived using using an object detector.`,name:"visual_embeds"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.visual_attention_mask",description:`<strong>visual_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on visual embeddings. 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:"visual_attention_mask"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.visual_token_type_ids",description:`<strong>visual_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate different portions of the visual embeds.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a> The authors of VisualBERT set the
<em>visual_token_type_ids</em> to <em>1</em> for all tokens.`,name:"visual_token_type_ids"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.image_text_alignment",description:`<strong>image_text_alignment</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length, alignment_number)</code>, <em>optional</em>) &#x2014;
Image-Text alignment uses to decide the position IDs of the visual embeddings.`,name:"image_text_alignment"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VisualBertForQuestionAnswering.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, total_sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. A KLDivLoss is computed between the labels and the returned logits.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1191",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.34.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.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig"
>VisualBertConfig</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) — 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>) — 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>) — 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>) — 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.34.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ge=new tn({props:{$$slots:{default:[va]},$$scope:{ctx:J}}}),fe=new bt({props:{anchor:"transformers.VisualBertForQuestionAnswering.forward.example",$$slots:{default:[ya]},$$scope:{ctx:J}}}),at=new Y({}),rt=new F({props:{name:"class transformers.VisualBertForMultipleChoice",anchor:"transformers.VisualBertForMultipleChoice",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VisualBertForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig">VisualBertConfig</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.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1026"}}),it=new F({props:{name:"forward",anchor:"transformers.VisualBertForMultipleChoice.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = 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.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"visual_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_text_alignment",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"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.VisualBertForMultipleChoice.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.VisualBertForMultipleChoice.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, 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.VisualBertForMultipleChoice.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, 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.VisualBertForMultipleChoice.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, 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.VisualBertForMultipleChoice.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VisualBertForMultipleChoice.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, 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.VisualBertForMultipleChoice.forward.visual_embeds",description:`<strong>visual_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length, visual_embedding_dim)</code>, <em>optional</em>) &#x2014;
The embedded representation of the visual inputs, generally derived using using an object detector.`,name:"visual_embeds"},{anchor:"transformers.VisualBertForMultipleChoice.forward.visual_attention_mask",description:`<strong>visual_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on visual embeddings. 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:"visual_attention_mask"},{anchor:"transformers.VisualBertForMultipleChoice.forward.visual_token_type_ids",description:`<strong>visual_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate different portions of the visual embeds.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a> The authors of VisualBERT set the
<em>visual_token_type_ids</em> to <em>1</em> for all tokens.`,name:"visual_token_type_ids"},{anchor:"transformers.VisualBertForMultipleChoice.forward.image_text_alignment",description:`<strong>image_text_alignment</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length, alignment_number)</code>, <em>optional</em>) &#x2014;
Image-Text alignment uses to decide the position IDs of the visual embeddings.`,name:"image_text_alignment"},{anchor:"transformers.VisualBertForMultipleChoice.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.VisualBertForMultipleChoice.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.VisualBertForMultipleChoice.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VisualBertForMultipleChoice.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the multiple choice classification loss. Indices should be in <code>[0, ..., num_choices-1]</code> where <code>num_choices</code> is the size of the second dimension of the input tensors. (See
<code>input_ids</code> above)`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1037",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</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.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig"
>VisualBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <em>(1,)</em>, <em>optional</em>, returned when <code>labels</code> is provided) — Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) — <em>num_choices</em> is the second dimension of the input tensors. (see <em>input_ids</em> above).</p>
<p>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>) — 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>) — 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.34.0/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),be=new tn({props:{$$slots:{default:[Ta]},$$scope:{ctx:J}}}),Me=new bt({props:{anchor:"transformers.VisualBertForMultipleChoice.forward.example",$$slots:{default:[wa]},$$scope:{ctx:J}}}),lt=new Y({}),dt=new F({props:{name:"class transformers.VisualBertForVisualReasoning",anchor:"transformers.VisualBertForVisualReasoning",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VisualBertForVisualReasoning.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig">VisualBertConfig</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.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1305"}}),ct=new F({props:{name:"forward",anchor:"transformers.VisualBertForVisualReasoning.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = 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.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"visual_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_text_alignment",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"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.VisualBertForVisualReasoning.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.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.VisualBertForVisualReasoning.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.VisualBertForVisualReasoning.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.VisualBertForVisualReasoning.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.VisualBertForVisualReasoning.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VisualBertForVisualReasoning.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.VisualBertForVisualReasoning.forward.visual_embeds",description:`<strong>visual_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length, visual_embedding_dim)</code>, <em>optional</em>) &#x2014;
The embedded representation of the visual inputs, generally derived using using an object detector.`,name:"visual_embeds"},{anchor:"transformers.VisualBertForVisualReasoning.forward.visual_attention_mask",description:`<strong>visual_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on visual embeddings. 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:"visual_attention_mask"},{anchor:"transformers.VisualBertForVisualReasoning.forward.visual_token_type_ids",description:`<strong>visual_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate different portions of the visual embeds.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a> The authors of VisualBERT set the
<em>visual_token_type_ids</em> to <em>1</em> for all tokens.`,name:"visual_token_type_ids"},{anchor:"transformers.VisualBertForVisualReasoning.forward.image_text_alignment",description:`<strong>image_text_alignment</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length, alignment_number)</code>, <em>optional</em>) &#x2014;
Image-Text alignment uses to decide the position IDs of the visual embeddings.`,name:"image_text_alignment"},{anchor:"transformers.VisualBertForVisualReasoning.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.VisualBertForVisualReasoning.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.VisualBertForVisualReasoning.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VisualBertForVisualReasoning.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>. A classification loss is computed (Cross-Entropy) against these labels.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1317",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.34.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.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig"
>VisualBertConfig</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) — 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>) — 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>) — 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>) — 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.34.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ye=new tn({props:{$$slots:{default:[ka]},$$scope:{ctx:J}}}),Te=new bt({props:{anchor:"transformers.VisualBertForVisualReasoning.forward.example",$$slots:{default:[Ja]},$$scope:{ctx:J}}}),pt=new Y({}),ut=new F({props:{name:"class transformers.VisualBertForRegionToPhraseAlignment",anchor:"transformers.VisualBertForRegionToPhraseAlignment",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VisualBertForRegionToPhraseAlignment.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig">VisualBertConfig</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.34.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.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1465"}}),mt=new F({props:{name:"forward",anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.LongTensor] = 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.LongTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"visual_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"visual_token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"image_text_alignment",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"},{name:"region_to_phrase_position",val:": typing.Optional[torch.LongTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.VisualBertForRegionToPhraseAlignment.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.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.VisualBertForRegionToPhraseAlignment.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.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.VisualBertForRegionToPhraseAlignment.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.visual_embeds",description:`<strong>visual_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length, visual_embedding_dim)</code>, <em>optional</em>) &#x2014;
The embedded representation of the visual inputs, generally derived using using an object detector.`,name:"visual_embeds"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.visual_attention_mask",description:`<strong>visual_attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on visual embeddings. 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:"visual_attention_mask"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.visual_token_type_ids",description:`<strong>visual_token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate different portions of the visual embeds.</p>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a> The authors of VisualBERT set the
<em>visual_token_type_ids</em> to <em>1</em> for all tokens.`,name:"visual_token_type_ids"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.image_text_alignment",description:`<strong>image_text_alignment</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, visual_seq_length, alignment_number)</code>, <em>optional</em>) &#x2014;
Image-Text alignment uses to decide the position IDs of the visual embeddings.`,name:"image_text_alignment"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.region_to_phrase_position",description:`<strong>region_to_phrase_position</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, total_sequence_length)</code>, <em>optional</em>) &#x2014;
The positions depicting the position of the image embedding corresponding to the textual tokens.`,name:"region_to_phrase_position"},{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, total_sequence_length, visual_sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. KLDivLoss is computed against these labels and the
outputs from the attention layer.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1479",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.34.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.34.0/en/model_doc/visual_bert#transformers.VisualBertConfig"
>VisualBertConfig</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) — 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>) — 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>) — 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>) — 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.34.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ke=new tn({props:{$$slots:{default:[Va]},$$scope:{ctx:J}}}),Je=new bt({props:{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.example",$$slots:{default:[Ba]},$$scope:{ctx:J}}}),{c(){o=a("meta"),w=i(),p=a("p"),u=i(),f=a("h1"),s=a("a"),k=a("span"),_(Fe.$$.fragment),oo=i(),Mt=a("span"),Mt.textContent=as,yn=i(),S=a("h2"),se=a("a"),nn=a("span"),_(xe.$$.fragment),so=i(),vt=a("span"),vt.textContent=rs,Tn=i(),Ie=a("p"),Ie.innerHTML=is,wn=i(),$e=a("p"),$e.textContent=ls,kn=i(),Ze=a("p"),Ze.innerHTML=ds,Jn=i(),Re=a("p"),Re.textContent=cs,Vn=i(),Xe=a("ol"),Xe.innerHTML=ps,Bn=i(),P=a("h2"),ae=a("a"),on=a("span"),_(Ne.$$.fragment),ao=i(),yt=a("span"),yt.textContent=us,Un=i(),Ge=a("p"),Ge.textContent=ms,jn=i(),Ae=a("p"),Ae.textContent=hs,Cn=i(),He=a("p"),He.innerHTML=gs,zn=i(),qe=a("ul"),qe.innerHTML=fs,Wn=i(),Ee=a("p"),Ee.innerHTML=_s,Fn=i(),_(Le.$$.fragment),xn=i(),Qe=a("p"),Qe.innerHTML=bs,In=i(),O=a("h2"),re=a("a"),sn=a("span"),_(Ye.$$.fragment),ro=i(),Tt=a("span"),Tt.textContent=Ms,$n=i(),W=a("div"),_(Se.$$.fragment),io=i(),wt=a("p"),wt.innerHTML=vs,lo=i(),kt=a("p"),kt.innerHTML=ys,co=i(),_(ie.$$.fragment),Zn=i(),D=a("h2"),le=a("a"),an=a("span"),_(Pe.$$.fragment),po=i(),Jt=a("span"),Jt.textContent=Ts,Rn=i(),V=a("div"),_(Oe.$$.fragment),uo=i(),Vt=a("p"),Vt.innerHTML=ws,mo=i(),Bt=a("p"),Bt.innerHTML=ks,ho=i(),Ut=a("p"),Ut.innerHTML=Js,go=i(),I=a("div"),_(De.$$.fragment),fo=i(),jt=a("p"),jt.innerHTML=Vs,_o=i(),_(de.$$.fragment),bo=i(),_(ce.$$.fragment),Xn=i(),K=a("h2"),pe=a("a"),rn=a("span"),_(Ke.$$.fragment),Mo=i(),Ct=a("span"),Ct.textContent=Bs,Nn=i(),B=a("div"),_(et.$$.fragment),vo=i(),zt=a("p"),zt.innerHTML=Us,yo=i(),Wt=a("p"),Wt.innerHTML=js,To=i(),Ft=a("p"),Ft.innerHTML=Cs,wo=i(),$=a("div"),_(tt.$$.fragment),ko=i(),xt=a("p"),xt.innerHTML=zs,Jo=i(),_(ue.$$.fragment),Vo=i(),_(me.$$.fragment),Gn=i(),ee=a("h2"),he=a("a"),ln=a("span"),_(nt.$$.fragment),Bo=i(),It=a("span"),It.textContent=Ws,An=i(),U=a("div"),_(ot.$$.fragment),Uo=i(),$t=a("p"),$t.textContent=Fs,jo=i(),Zt=a("p"),Zt.innerHTML=xs,Co=i(),Rt=a("p"),Rt.innerHTML=Is,zo=i(),Z=a("div"),_(st.$$.fragment),Wo=i(),Xt=a("p"),Xt.innerHTML=$s,Fo=i(),_(ge.$$.fragment),xo=i(),_(fe.$$.fragment),Hn=i(),te=a("h2"),_e=a("a"),dn=a("span"),_(at.$$.fragment),Io=i(),Nt=a("span"),Nt.textContent=Zs,qn=i(),j=a("div"),_(rt.$$.fragment),$o=i(),Gt=a("p"),Gt.textContent=Rs,Zo=i(),At=a("p"),At.innerHTML=Xs,Ro=i(),Ht=a("p"),Ht.innerHTML=Ns,Xo=i(),R=a("div"),_(it.$$.fragment),No=i(),qt=a("p"),qt.innerHTML=Gs,Go=i(),_(be.$$.fragment),Ao=i(),_(Me.$$.fragment),En=i(),ne=a("h2"),ve=a("a"),cn=a("span"),_(lt.$$.fragment),Ho=i(),Et=a("span"),Et.textContent=As,Ln=i(),C=a("div"),_(dt.$$.fragment),qo=i(),Lt=a("p"),Lt.textContent=Hs,Eo=i(),Qt=a("p"),Qt.innerHTML=qs,Lo=i(),Yt=a("p"),Yt.innerHTML=Es,Qo=i(),X=a("div"),_(ct.$$.fragment),Yo=i(),St=a("p"),St.innerHTML=Ls,So=i(),_(ye.$$.fragment),Po=i(),_(Te.$$.fragment),Qn=i(),oe=a("h2"),we=a("a"),pn=a("span"),_(pt.$$.fragment),Oo=i(),Pt=a("span"),Pt.textContent=Qs,Yn=i(),z=a("div"),_(ut.$$.fragment),Do=i(),Ot=a("p"),Ot.textContent=Ys,Ko=i(),Dt=a("p"),Dt.innerHTML=Ss,es=i(),Kt=a("p"),Kt.innerHTML=Ps,ts=i(),N=a("div"),_(mt.$$.fragment),ns=i(),en=a("p"),en.innerHTML=Os,os=i(),_(ke.$$.fragment),ss=i(),_(Je.$$.fragment),Sn=i(),un=a("p"),this.h()},l(e){const d=ha("svelte-1phssyn",document.head);o=r(d,"META",{name:!0,content:!0}),d.forEach(t),w=l(e),p=r(e,"P",{}),g(p).forEach(t),u=l(e),f=r(e,"H1",{class:!0});var ht=g(f);s=r(ht,"A",{id:!0,class:!0,href:!0});var mn=g(s);k=r(mn,"SPAN",{});var hn=g(k);b(Fe.$$.fragment,hn),hn.forEach(t),mn.forEach(t),oo=l(ht),Mt=r(ht,"SPAN",{"data-svelte-h":!0}),m(Mt)!=="svelte-1uupx1o"&&(Mt.textContent=as),ht.forEach(t),yn=l(e),S=r(e,"H2",{class:!0});var gt=g(S);se=r(gt,"A",{id:!0,class:!0,href:!0});var gn=g(se);nn=r(gn,"SPAN",{});var fn=g(nn);b(xe.$$.fragment,fn),fn.forEach(t),gn.forEach(t),so=l(gt),vt=r(gt,"SPAN",{"data-svelte-h":!0}),m(vt)!=="svelte-1jsw1pg"&&(vt.textContent=rs),gt.forEach(t),Tn=l(e),Ie=r(e,"P",{"data-svelte-h":!0}),m(Ie)!=="svelte-tfmd3r"&&(Ie.innerHTML=is),wn=l(e),$e=r(e,"P",{"data-svelte-h":!0}),m($e)!=="svelte-vfdo9a"&&($e.textContent=ls),kn=l(e),Ze=r(e,"P",{"data-svelte-h":!0}),m(Ze)!=="svelte-1txydnv"&&(Ze.innerHTML=ds),Jn=l(e),Re=r(e,"P",{"data-svelte-h":!0}),m(Re)!=="svelte-axv494"&&(Re.textContent=cs),Vn=l(e),Xe=r(e,"OL",{"data-svelte-h":!0}),m(Xe)!=="svelte-z3w2f8"&&(Xe.innerHTML=ps),Bn=l(e),P=r(e,"H2",{class:!0});var ft=g(P);ae=r(ft,"A",{id:!0,class:!0,href:!0});var _n=g(ae);on=r(_n,"SPAN",{});var bn=g(on);b(Ne.$$.fragment,bn),bn.forEach(t),_n.forEach(t),ao=l(ft),yt=r(ft,"SPAN",{"data-svelte-h":!0}),m(yt)!=="svelte-jwh4bg"&&(yt.textContent=us),ft.forEach(t),Un=l(e),Ge=r(e,"P",{"data-svelte-h":!0}),m(Ge)!=="svelte-iioag5"&&(Ge.textContent=ms),jn=l(e),Ae=r(e,"P",{"data-svelte-h":!0}),m(Ae)!=="svelte-icjdc3"&&(Ae.textContent=hs),Cn=l(e),He=r(e,"P",{"data-svelte-h":!0}),m(He)!=="svelte-1x2gn82"&&(He.innerHTML=gs),zn=l(e),qe=r(e,"UL",{"data-svelte-h":!0}),m(qe)!=="svelte-boj5tg"&&(qe.innerHTML=fs),Wn=l(e),Ee=r(e,"P",{"data-svelte-h":!0}),m(Ee)!=="svelte-1fh404o"&&(Ee.innerHTML=_s),Fn=l(e),b(Le.$$.fragment,e),xn=l(e),Qe=r(e,"P",{"data-svelte-h":!0}),m(Qe)!=="svelte-1d1xjnh"&&(Qe.innerHTML=bs),In=l(e),O=r(e,"H2",{class:!0});var _t=g(O);re=r(_t,"A",{id:!0,class:!0,href:!0});var Mn=g(re);sn=r(Mn,"SPAN",{});var vn=g(sn);b(Ye.$$.fragment,vn),vn.forEach(t),Mn.forEach(t),ro=l(_t),Tt=r(_t,"SPAN",{"data-svelte-h":!0}),m(Tt)!=="svelte-t54q82"&&(Tt.textContent=Ms),_t.forEach(t),$n=l(e),W=r(e,"DIV",{class:!0});var G=g(W);b(Se.$$.fragment,G),io=l(G),wt=r(G,"P",{"data-svelte-h":!0}),m(wt)!=="svelte-k1xsdx"&&(wt.innerHTML=vs),lo=l(G),kt=r(G,"P",{"data-svelte-h":!0}),m(kt)!=="svelte-10kqkkl"&&(kt.innerHTML=ys),co=l(G),b(ie.$$.fragment,G),G.forEach(t),Zn=l(e),D=r(e,"H2",{class:!0});var On=g(D);le=r(On,"A",{id:!0,class:!0,href:!0});var Ds=g(le);an=r(Ds,"SPAN",{});var Ks=g(an);b(Pe.$$.fragment,Ks),Ks.forEach(t),Ds.forEach(t),po=l(On),Jt=r(On,"SPAN",{"data-svelte-h":!0}),m(Jt)!=="svelte-1eh00lv"&&(Jt.textContent=Ts),On.forEach(t),Rn=l(e),V=r(e,"DIV",{class:!0});var A=g(V);b(Oe.$$.fragment,A),uo=l(A),Vt=r(A,"P",{"data-svelte-h":!0}),m(Vt)!=="svelte-jtclee"&&(Vt.innerHTML=ws),mo=l(A),Bt=r(A,"P",{"data-svelte-h":!0}),m(Bt)!=="svelte-hswkmf"&&(Bt.innerHTML=ks),ho=l(A),Ut=r(A,"P",{"data-svelte-h":!0}),m(Ut)!=="svelte-1araf9a"&&(Ut.innerHTML=Js),go=l(A),I=r(A,"DIV",{class:!0});var Ve=g(I);b(De.$$.fragment,Ve),fo=l(Ve),jt=r(Ve,"P",{"data-svelte-h":!0}),m(jt)!=="svelte-1gtjkaj"&&(jt.innerHTML=Vs),_o=l(Ve),b(de.$$.fragment,Ve),bo=l(Ve),b(ce.$$.fragment,Ve),Ve.forEach(t),A.forEach(t),Xn=l(e),K=r(e,"H2",{class:!0});var Dn=g(K);pe=r(Dn,"A",{id:!0,class:!0,href:!0});var ea=g(pe);rn=r(ea,"SPAN",{});var ta=g(rn);b(Ke.$$.fragment,ta),ta.forEach(t),ea.forEach(t),Mo=l(Dn),Ct=r(Dn,"SPAN",{"data-svelte-h":!0}),m(Ct)!=="svelte-zjutra"&&(Ct.textContent=Bs),Dn.forEach(t),Nn=l(e),B=r(e,"DIV",{class:!0});var H=g(B);b(et.$$.fragment,H),vo=l(H),zt=r(H,"P",{"data-svelte-h":!0}),m(zt)!=="svelte-izdyyc"&&(zt.innerHTML=Us),yo=l(H),Wt=r(H,"P",{"data-svelte-h":!0}),m(Wt)!=="svelte-hmtw9k"&&(Wt.innerHTML=js),To=l(H),Ft=r(H,"P",{"data-svelte-h":!0}),m(Ft)!=="svelte-hswkmf"&&(Ft.innerHTML=Cs),wo=l(H),$=r(H,"DIV",{class:!0});var Be=g($);b(tt.$$.fragment,Be),ko=l(Be),xt=r(Be,"P",{"data-svelte-h":!0}),m(xt)!=="svelte-i6atq9"&&(xt.innerHTML=zs),Jo=l(Be),b(ue.$$.fragment,Be),Vo=l(Be),b(me.$$.fragment,Be),Be.forEach(t),H.forEach(t),Gn=l(e),ee=r(e,"H2",{class:!0});var Kn=g(ee);he=r(Kn,"A",{id:!0,class:!0,href:!0});var na=g(he);ln=r(na,"SPAN",{});var oa=g(ln);b(nt.$$.fragment,oa),oa.forEach(t),na.forEach(t),Bo=l(Kn),It=r(Kn,"SPAN",{"data-svelte-h":!0}),m(It)!=="svelte-14nbep"&&(It.textContent=Ws),Kn.forEach(t),An=l(e),U=r(e,"DIV",{class:!0});var q=g(U);b(ot.$$.fragment,q),Uo=l(q),$t=r(q,"P",{"data-svelte-h":!0}),m($t)!=="svelte-1kebopj"&&($t.textContent=Fs),jo=l(q),Zt=r(q,"P",{"data-svelte-h":!0}),m(Zt)!=="svelte-hmtw9k"&&(Zt.innerHTML=xs),Co=l(q),Rt=r(q,"P",{"data-svelte-h":!0}),m(Rt)!=="svelte-hswkmf"&&(Rt.innerHTML=Is),zo=l(q),Z=r(q,"DIV",{class:!0});var Ue=g(Z);b(st.$$.fragment,Ue),Wo=l(Ue),Xt=r(Ue,"P",{"data-svelte-h":!0}),m(Xt)!=="svelte-1w4v26n"&&(Xt.innerHTML=$s),Fo=l(Ue),b(ge.$$.fragment,Ue),xo=l(Ue),b(fe.$$.fragment,Ue),Ue.forEach(t),q.forEach(t),Hn=l(e),te=r(e,"H2",{class:!0});var eo=g(te);_e=r(eo,"A",{id:!0,class:!0,href:!0});var sa=g(_e);dn=r(sa,"SPAN",{});var aa=g(dn);b(at.$$.fragment,aa),aa.forEach(t),sa.forEach(t),Io=l(eo),Nt=r(eo,"SPAN",{"data-svelte-h":!0}),m(Nt)!=="svelte-87qjjq"&&(Nt.textContent=Zs),eo.forEach(t),qn=l(e),j=r(e,"DIV",{class:!0});var E=g(j);b(rt.$$.fragment,E),$o=l(E),Gt=r(E,"P",{"data-svelte-h":!0}),m(Gt)!=="svelte-11n5saq"&&(Gt.textContent=Rs),Zo=l(E),At=r(E,"P",{"data-svelte-h":!0}),m(At)!=="svelte-hmtw9k"&&(At.innerHTML=Xs),Ro=l(E),Ht=r(E,"P",{"data-svelte-h":!0}),m(Ht)!=="svelte-hswkmf"&&(Ht.innerHTML=Ns),Xo=l(E),R=r(E,"DIV",{class:!0});var je=g(R);b(it.$$.fragment,je),No=l(je),qt=r(je,"P",{"data-svelte-h":!0}),m(qt)!=="svelte-1cqt6nf"&&(qt.innerHTML=Gs),Go=l(je),b(be.$$.fragment,je),Ao=l(je),b(Me.$$.fragment,je),je.forEach(t),E.forEach(t),En=l(e),ne=r(e,"H2",{class:!0});var to=g(ne);ve=r(to,"A",{id:!0,class:!0,href:!0});var ra=g(ve);cn=r(ra,"SPAN",{});var ia=g(cn);b(lt.$$.fragment,ia),ia.forEach(t),ra.forEach(t),Ho=l(to),Et=r(to,"SPAN",{"data-svelte-h":!0}),m(Et)!=="svelte-t1srzr"&&(Et.textContent=As),to.forEach(t),Ln=l(e),C=r(e,"DIV",{class:!0});var L=g(C);b(dt.$$.fragment,L),qo=l(L),Lt=r(L,"P",{"data-svelte-h":!0}),m(Lt)!=="svelte-15dl5em"&&(Lt.textContent=Hs),Eo=l(L),Qt=r(L,"P",{"data-svelte-h":!0}),m(Qt)!=="svelte-hmtw9k"&&(Qt.innerHTML=qs),Lo=l(L),Yt=r(L,"P",{"data-svelte-h":!0}),m(Yt)!=="svelte-hswkmf"&&(Yt.innerHTML=Es),Qo=l(L),X=r(L,"DIV",{class:!0});var Ce=g(X);b(ct.$$.fragment,Ce),Yo=l(Ce),St=r(Ce,"P",{"data-svelte-h":!0}),m(St)!=="svelte-ogw0jz"&&(St.innerHTML=Ls),So=l(Ce),b(ye.$$.fragment,Ce),Po=l(Ce),b(Te.$$.fragment,Ce),Ce.forEach(t),L.forEach(t),Qn=l(e),oe=r(e,"H2",{class:!0});var no=g(oe);we=r(no,"A",{id:!0,class:!0,href:!0});var la=g(we);pn=r(la,"SPAN",{});var da=g(pn);b(pt.$$.fragment,da),da.forEach(t),la.forEach(t),Oo=l(no),Pt=r(no,"SPAN",{"data-svelte-h":!0}),m(Pt)!=="svelte-2q3jo0"&&(Pt.textContent=Qs),no.forEach(t),Yn=l(e),z=r(e,"DIV",{class:!0});var Q=g(z);b(ut.$$.fragment,Q),Do=l(Q),Ot=r(Q,"P",{"data-svelte-h":!0}),m(Ot)!=="svelte-5zhgq1"&&(Ot.textContent=Ys),Ko=l(Q),Dt=r(Q,"P",{"data-svelte-h":!0}),m(Dt)!=="svelte-hmtw9k"&&(Dt.innerHTML=Ss),es=l(Q),Kt=r(Q,"P",{"data-svelte-h":!0}),m(Kt)!=="svelte-hswkmf"&&(Kt.innerHTML=Ps),ts=l(Q),N=r(Q,"DIV",{class:!0});var ze=g(N);b(mt.$$.fragment,ze),ns=l(ze),en=r(ze,"P",{"data-svelte-h":!0}),m(en)!=="svelte-1e8i8jp"&&(en.innerHTML=Os),os=l(ze),b(ke.$$.fragment,ze),ss=l(ze),b(Je.$$.fragment,ze),ze.forEach(t),Q.forEach(t),Sn=l(e),un=r(e,"P",{}),g(un).forEach(t),this.h()},h(){h(o,"name","hf:doc:metadata"),h(o,"content",JSON.stringify(ja)),h(s,"id","visualbert"),h(s,"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"),h(s,"href","#visualbert"),h(f,"class","relative group"),h(se,"id","overview"),h(se,"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"),h(se,"href","#overview"),h(S,"class","relative group"),h(ae,"id","usage"),h(ae,"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"),h(ae,"href","#usage"),h(P,"class","relative group"),h(re,"id","transformers.VisualBertConfig"),h(re,"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"),h(re,"href","#transformers.VisualBertConfig"),h(O,"class","relative group"),h(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(le,"id","transformers.VisualBertModel"),h(le,"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"),h(le,"href","#transformers.VisualBertModel"),h(D,"class","relative group"),h(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(pe,"id","transformers.VisualBertForPreTraining"),h(pe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(pe,"href","#transformers.VisualBertForPreTraining"),h(K,"class","relative group"),h($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(he,"id","transformers.VisualBertForQuestionAnswering"),h(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(he,"href","#transformers.VisualBertForQuestionAnswering"),h(ee,"class","relative group"),h(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(_e,"id","transformers.VisualBertForMultipleChoice"),h(_e,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(_e,"href","#transformers.VisualBertForMultipleChoice"),h(te,"class","relative group"),h(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(ve,"id","transformers.VisualBertForVisualReasoning"),h(ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(ve,"href","#transformers.VisualBertForVisualReasoning"),h(ne,"class","relative group"),h(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(we,"id","transformers.VisualBertForRegionToPhraseAlignment"),h(we,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(we,"href","#transformers.VisualBertForRegionToPhraseAlignment"),h(oe,"class","relative group"),h(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,d){n(document.head,o),c(e,w,d),c(e,p,d),c(e,u,d),c(e,f,d),n(f,s),n(s,k),M(Fe,k,null),n(f,oo),n(f,Mt),c(e,yn,d),c(e,S,d),n(S,se),n(se,nn),M(xe,nn,null),n(S,so),n(S,vt),c(e,Tn,d),c(e,Ie,d),c(e,wn,d),c(e,$e,d),c(e,kn,d),c(e,Ze,d),c(e,Jn,d),c(e,Re,d),c(e,Vn,d),c(e,Xe,d),c(e,Bn,d),c(e,P,d),n(P,ae),n(ae,on),M(Ne,on,null),n(P,ao),n(P,yt),c(e,Un,d),c(e,Ge,d),c(e,jn,d),c(e,Ae,d),c(e,Cn,d),c(e,He,d),c(e,zn,d),c(e,qe,d),c(e,Wn,d),c(e,Ee,d),c(e,Fn,d),M(Le,e,d),c(e,xn,d),c(e,Qe,d),c(e,In,d),c(e,O,d),n(O,re),n(re,sn),M(Ye,sn,null),n(O,ro),n(O,Tt),c(e,$n,d),c(e,W,d),M(Se,W,null),n(W,io),n(W,wt),n(W,lo),n(W,kt),n(W,co),M(ie,W,null),c(e,Zn,d),c(e,D,d),n(D,le),n(le,an),M(Pe,an,null),n(D,po),n(D,Jt),c(e,Rn,d),c(e,V,d),M(Oe,V,null),n(V,uo),n(V,Vt),n(V,mo),n(V,Bt),n(V,ho),n(V,Ut),n(V,go),n(V,I),M(De,I,null),n(I,fo),n(I,jt),n(I,_o),M(de,I,null),n(I,bo),M(ce,I,null),c(e,Xn,d),c(e,K,d),n(K,pe),n(pe,rn),M(Ke,rn,null),n(K,Mo),n(K,Ct),c(e,Nn,d),c(e,B,d),M(et,B,null),n(B,vo),n(B,zt),n(B,yo),n(B,Wt),n(B,To),n(B,Ft),n(B,wo),n(B,$),M(tt,$,null),n($,ko),n($,xt),n($,Jo),M(ue,$,null),n($,Vo),M(me,$,null),c(e,Gn,d),c(e,ee,d),n(ee,he),n(he,ln),M(nt,ln,null),n(ee,Bo),n(ee,It),c(e,An,d),c(e,U,d),M(ot,U,null),n(U,Uo),n(U,$t),n(U,jo),n(U,Zt),n(U,Co),n(U,Rt),n(U,zo),n(U,Z),M(st,Z,null),n(Z,Wo),n(Z,Xt),n(Z,Fo),M(ge,Z,null),n(Z,xo),M(fe,Z,null),c(e,Hn,d),c(e,te,d),n(te,_e),n(_e,dn),M(at,dn,null),n(te,Io),n(te,Nt),c(e,qn,d),c(e,j,d),M(rt,j,null),n(j,$o),n(j,Gt),n(j,Zo),n(j,At),n(j,Ro),n(j,Ht),n(j,Xo),n(j,R),M(it,R,null),n(R,No),n(R,qt),n(R,Go),M(be,R,null),n(R,Ao),M(Me,R,null),c(e,En,d),c(e,ne,d),n(ne,ve),n(ve,cn),M(lt,cn,null),n(ne,Ho),n(ne,Et),c(e,Ln,d),c(e,C,d),M(dt,C,null),n(C,qo),n(C,Lt),n(C,Eo),n(C,Qt),n(C,Lo),n(C,Yt),n(C,Qo),n(C,X),M(ct,X,null),n(X,Yo),n(X,St),n(X,So),M(ye,X,null),n(X,Po),M(Te,X,null),c(e,Qn,d),c(e,oe,d),n(oe,we),n(we,pn),M(pt,pn,null),n(oe,Oo),n(oe,Pt),c(e,Yn,d),c(e,z,d),M(ut,z,null),n(z,Do),n(z,Ot),n(z,Ko),n(z,Dt),n(z,es),n(z,Kt),n(z,ts),n(z,N),M(mt,N,null),n(N,ns),n(N,en),n(N,os),M(ke,N,null),n(N,ss),M(Je,N,null),c(e,Sn,d),c(e,un,d),Pn=!0},p(e,[d]){const ht={};d&2&&(ht.$$scope={dirty:d,ctx:e}),ie.$set(ht);const mn={};d&2&&(mn.$$scope={dirty:d,ctx:e}),de.$set(mn);const hn={};d&2&&(hn.$$scope={dirty:d,ctx:e}),ce.$set(hn);const gt={};d&2&&(gt.$$scope={dirty:d,ctx:e}),ue.$set(gt);const gn={};d&2&&(gn.$$scope={dirty:d,ctx:e}),me.$set(gn);const fn={};d&2&&(fn.$$scope={dirty:d,ctx:e}),ge.$set(fn);const ft={};d&2&&(ft.$$scope={dirty:d,ctx:e}),fe.$set(ft);const _n={};d&2&&(_n.$$scope={dirty:d,ctx:e}),be.$set(_n);const bn={};d&2&&(bn.$$scope={dirty:d,ctx:e}),Me.$set(bn);const _t={};d&2&&(_t.$$scope={dirty:d,ctx:e}),ye.$set(_t);const Mn={};d&2&&(Mn.$$scope={dirty:d,ctx:e}),Te.$set(Mn);const vn={};d&2&&(vn.$$scope={dirty:d,ctx:e}),ke.$set(vn);const G={};d&2&&(G.$$scope={dirty:d,ctx:e}),Je.$set(G)},i(e){Pn||(v(Fe.$$.fragment,e),v(xe.$$.fragment,e),v(Ne.$$.fragment,e),v(Le.$$.fragment,e),v(Ye.$$.fragment,e),v(Se.$$.fragment,e),v(ie.$$.fragment,e),v(Pe.$$.fragment,e),v(Oe.$$.fragment,e),v(De.$$.fragment,e),v(de.$$.fragment,e),v(ce.$$.fragment,e),v(Ke.$$.fragment,e),v(et.$$.fragment,e),v(tt.$$.fragment,e),v(ue.$$.fragment,e),v(me.$$.fragment,e),v(nt.$$.fragment,e),v(ot.$$.fragment,e),v(st.$$.fragment,e),v(ge.$$.fragment,e),v(fe.$$.fragment,e),v(at.$$.fragment,e),v(rt.$$.fragment,e),v(it.$$.fragment,e),v(be.$$.fragment,e),v(Me.$$.fragment,e),v(lt.$$.fragment,e),v(dt.$$.fragment,e),v(ct.$$.fragment,e),v(ye.$$.fragment,e),v(Te.$$.fragment,e),v(pt.$$.fragment,e),v(ut.$$.fragment,e),v(mt.$$.fragment,e),v(ke.$$.fragment,e),v(Je.$$.fragment,e),Pn=!0)},o(e){y(Fe.$$.fragment,e),y(xe.$$.fragment,e),y(Ne.$$.fragment,e),y(Le.$$.fragment,e),y(Ye.$$.fragment,e),y(Se.$$.fragment,e),y(ie.$$.fragment,e),y(Pe.$$.fragment,e),y(Oe.$$.fragment,e),y(De.$$.fragment,e),y(de.$$.fragment,e),y(ce.$$.fragment,e),y(Ke.$$.fragment,e),y(et.$$.fragment,e),y(tt.$$.fragment,e),y(ue.$$.fragment,e),y(me.$$.fragment,e),y(nt.$$.fragment,e),y(ot.$$.fragment,e),y(st.$$.fragment,e),y(ge.$$.fragment,e),y(fe.$$.fragment,e),y(at.$$.fragment,e),y(rt.$$.fragment,e),y(it.$$.fragment,e),y(be.$$.fragment,e),y(Me.$$.fragment,e),y(lt.$$.fragment,e),y(dt.$$.fragment,e),y(ct.$$.fragment,e),y(ye.$$.fragment,e),y(Te.$$.fragment,e),y(pt.$$.fragment,e),y(ut.$$.fragment,e),y(mt.$$.fragment,e),y(ke.$$.fragment,e),y(Je.$$.fragment,e),Pn=!1},d(e){e&&(t(w),t(p),t(u),t(f),t(yn),t(S),t(Tn),t(Ie),t(wn),t($e),t(kn),t(Ze),t(Jn),t(Re),t(Vn),t(Xe),t(Bn),t(P),t(Un),t(Ge),t(jn),t(Ae),t(Cn),t(He),t(zn),t(qe),t(Wn),t(Ee),t(Fn),t(xn),t(Qe),t(In),t(O),t($n),t(W),t(Zn),t(D),t(Rn),t(V),t(Xn),t(K),t(Nn),t(B),t(Gn),t(ee),t(An),t(U),t(Hn),t(te),t(qn),t(j),t(En),t(ne),t(Ln),t(C),t(Qn),t(oe),t(Yn),t(z),t(Sn),t(un)),t(o),T(Fe),T(xe),T(Ne),T(Le,e),T(Ye),T(Se),T(ie),T(Pe),T(Oe),T(De),T(de),T(ce),T(Ke),T(et),T(tt),T(ue),T(me),T(nt),T(ot),T(st),T(ge),T(fe),T(at),T(rt),T(it),T(be),T(Me),T(lt),T(dt),T(ct),T(ye),T(Te),T(pt),T(ut),T(mt),T(ke),T(Je)}}}const ja={local:"visualbert",sections:[{local:"overview",title:"Overview"},{local:"usage",title:"Usage"},{local:"transformers.VisualBertConfig",title:"VisualBertConfig"},{local:"transformers.VisualBertModel",title:"VisualBertModel"},{local:"transformers.VisualBertForPreTraining",title:"VisualBertForPreTraining"},{local:"transformers.VisualBertForQuestionAnswering",title:"VisualBertForQuestionAnswering"},{local:"transformers.VisualBertForMultipleChoice",title:"VisualBertForMultipleChoice"},{local:"transformers.VisualBertForVisualReasoning",title:"VisualBertForVisualReasoning"},{local:"transformers.VisualBertForRegionToPhraseAlignment",title:"VisualBertForRegionToPhraseAlignment"}],title:"VisualBERT"};function Ca(J){return pa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ra extends ua{constructor(o){super(),ma(this,o,Ca,Ua,ca,{})}}export{Ra as component};
