import{S as md,i as fd,s as gd,e as n,k as h,w as y,t as i,M as _d,c as s,d as o,m as u,a,x as M,h as l,b as c,G as e,g as _,y as T,q as w,o as k,B as V,v as bd,L as Ht}from"../../chunks/vendor-hf-doc-builder.js";import{T as Fo}from"../../chunks/Tip-hf-doc-builder.js";import{D as $}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Se}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as H}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as St}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function vd(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function yd(B){let d,v,g,m,b;return{c(){d=n("p"),v=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),m=i("Module"),b=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var J=a(g);m=l(J,"Module"),J.forEach(o),b=l(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(r,p){_(r,d,p),e(d,v),e(d,g),e(g,m),e(d,b)},d(r){r&&o(d)}}}function Md(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function Td(B){let d,v,g,m,b;return{c(){d=n("p"),v=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),m=i("Module"),b=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var J=a(g);m=l(J,"Module"),J.forEach(o),b=l(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(r,p){_(r,d,p),e(d,v),e(d,g),e(g,m),e(d,b)},d(r){r&&o(d)}}}function wd(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function kd(B){let d,v,g,m,b;return{c(){d=n("p"),v=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),m=i("Module"),b=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var J=a(g);m=l(J,"Module"),J.forEach(o),b=l(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(r,p){_(r,d,p),e(d,v),e(d,g),e(g,m),e(d,b)},d(r){r&&o(d)}}}function Vd(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function Bd(B){let d,v,g,m,b;return{c(){d=n("p"),v=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),m=i("Module"),b=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var J=a(g);m=l(J,"Module"),J.forEach(o),b=l(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(r,p){_(r,d,p),e(d,v),e(d,g),e(g,m),e(d,b)},d(r){r&&o(d)}}}function Jd(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function Ud(B){let d,v,g,m,b;return{c(){d=n("p"),v=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),m=i("Module"),b=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var J=a(g);m=l(J,"Module"),J.forEach(o),b=l(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(r,p){_(r,d,p),e(d,v),e(d,g),e(g,m),e(d,b)},d(r){r&&o(d)}}}function jd(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function zd(B){let d,v,g,m,b;return{c(){d=n("p"),v=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),m=i("Module"),b=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=s(p,"CODE",{});var J=a(g);m=l(J,"Module"),J.forEach(o),b=l(p,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),p.forEach(o)},m(r,p){_(r,d,p),e(d,v),e(d,g),e(g,m),e(d,b)},d(r){r&&o(d)}}}function Wd(B){let d,v,g,m,b;return m=new Se({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`}}),{c(){d=n("p"),v=i("Example:"),g=h(),y(m.$$.fragment)},l(r){d=s(r,"P",{});var p=a(d);v=l(p,"Example:"),p.forEach(o),g=u(r),M(m.$$.fragment,r)},m(r,p){_(r,d,p),e(d,v),_(r,g,p),T(m,r,p),b=!0},p:Ht,i(r){b||(w(m.$$.fragment,r),b=!0)},o(r){k(m.$$.fragment,r),b=!1},d(r){r&&o(d),r&&o(g),V(m,r)}}}function Fd(B){let d,v,g,m,b,r,p,J,Js,Bn,L,me,Io,He,Us,Co,js,Jn,fe,zs,Le,Ws,Fs,Un,Lt,Is,jn,Ot,$o,Cs,zn,Dt,$s,Wn,ge,Eo,Oe,Es,Kt,Rs,Zs,xs,Ro,Zo,Xs,Fn,O,_e,xo,De,Ns,Xo,As,In,eo,Gs,Cn,to,qs,$n,be,Qs,oo,Ys,Ps,En,ve,No,no,Ke,Ss,Hs,Ls,Ao,so,et,Os,Ds,Rn,ye,Ks,ao,ea,ta,Zn,tt,xn,A,oa,ot,na,sa,nt,aa,ra,Xn,D,Me,Go,st,ia,qo,la,Nn,C,at,da,K,ca,ro,pa,ha,rt,ua,ma,fa,ee,ga,io,_a,ba,lo,va,ya,Ma,Te,An,te,we,Qo,it,Ta,Yo,wa,Gn,U,lt,ka,dt,Va,co,Ba,Ja,Ua,ct,ja,pt,za,Wa,Fa,ht,Ia,ut,Ca,$a,Ea,E,mt,Ra,oe,Za,po,xa,Xa,Po,Na,Aa,Ga,ke,qa,Ve,qn,ne,Be,So,ft,Qa,Ho,Ya,Qn,j,gt,Pa,se,Sa,Lo,Ha,La,Oo,Oa,Da,Ka,_t,er,ho,tr,or,nr,bt,sr,vt,ar,rr,ir,R,yt,lr,ae,dr,uo,cr,pr,Do,hr,ur,mr,Je,fr,Ue,Yn,re,je,Ko,Mt,gr,en,_r,Pn,z,Tt,br,tn,vr,yr,wt,Mr,mo,Tr,wr,kr,kt,Vr,Vt,Br,Jr,Ur,Z,Bt,jr,ie,zr,fo,Wr,Fr,on,Ir,Cr,$r,ze,Er,We,Sn,le,Fe,nn,Jt,Rr,sn,Zr,Hn,W,Ut,xr,an,Xr,Nr,jt,Ar,go,Gr,qr,Qr,zt,Yr,Wt,Pr,Sr,Hr,x,Ft,Lr,de,Or,_o,Dr,Kr,rn,ei,ti,oi,Ie,ni,Ce,Ln,ce,$e,ln,It,si,dn,ai,On,F,Ct,ri,cn,ii,li,$t,di,bo,ci,pi,hi,Et,ui,Rt,mi,fi,gi,X,Zt,_i,pe,bi,vo,vi,yi,pn,Mi,Ti,wi,Ee,ki,Re,Dn,he,Ze,hn,xt,Vi,un,Bi,Kn,I,Xt,Ji,mn,Ui,ji,Nt,zi,yo,Wi,Fi,Ii,At,Ci,Gt,$i,Ei,Ri,N,qt,Zi,ue,xi,Mo,Xi,Ni,fn,Ai,Gi,qi,xe,Qi,Xe,es;return r=new H({}),He=new H({}),De=new H({}),tt=new Se({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`}}),st=new H({}),at=new $({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.30.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.30.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.30.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.30.0/src/transformers/models/visual_bert/configuration_visual_bert.py#L43"}}),Te=new St({props:{anchor:"transformers.VisualBertConfig.example",$$slots:{default:[vd]},$$scope:{ctx:B}}}),it=new H({}),lt=new $({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.30.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.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L677"}}),mt=new $({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.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.30.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L716",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ke=new Fo({props:{$$slots:{default:[yd]},$$scope:{ctx:B}}}),Ve=new St({props:{anchor:"transformers.VisualBertModel.forward.example",$$slots:{default:[Md]},$$scope:{ctx:B}}}),ft=new H({}),gt=new $({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.30.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.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L873"}}),yt=new $({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.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.30.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.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L891",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.30.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>) \u2014 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>) \u2014 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>) \u2014 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>) \u2014 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>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.visual_bert.modeling_visual_bert.VisualBertForPreTrainingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Je=new Fo({props:{$$slots:{default:[Td]},$$scope:{ctx:B}}}),Ue=new St({props:{anchor:"transformers.VisualBertForPreTraining.forward.example",$$slots:{default:[wd]},$$scope:{ctx:B}}}),Mt=new H({}),Tt=new $({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.30.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.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1177"}}),Bt=new $({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.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.30.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.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1189",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.30.0/en/model_doc/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) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ze=new Fo({props:{$$slots:{default:[kd]},$$scope:{ctx:B}}}),We=new St({props:{anchor:"transformers.VisualBertForQuestionAnswering.forward.example",$$slots:{default:[Vd]},$$scope:{ctx:B}}}),Jt=new H({}),Ut=new $({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.30.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.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1024"}}),Ft=new $({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.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.30.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.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1035",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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) \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 <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>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ie=new Fo({props:{$$slots:{default:[Bd]},$$scope:{ctx:B}}}),Ce=new St({props:{anchor:"transformers.VisualBertForMultipleChoice.forward.example",$$slots:{default:[Jd]},$$scope:{ctx:B}}}),It=new H({}),Ct=new $({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.30.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.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1303"}}),Zt=new $({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.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.30.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.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1315",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.30.0/en/model_doc/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) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ee=new Fo({props:{$$slots:{default:[Ud]},$$scope:{ctx:B}}}),Re=new St({props:{anchor:"transformers.VisualBertForVisualReasoning.forward.example",$$slots:{default:[jd]},$$scope:{ctx:B}}}),xt=new H({}),Xt=new $({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.30.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.30.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1463"}}),qt=new $({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.30.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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.30.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.30.0/src/transformers/models/visual_bert/modeling_visual_bert.py#L1477",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.30.0/en/model_doc/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) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),xe=new Fo({props:{$$slots:{default:[zd]},$$scope:{ctx:B}}}),Xe=new St({props:{anchor:"transformers.VisualBertForRegionToPhraseAlignment.forward.example",$$slots:{default:[Wd]},$$scope:{ctx:B}}}),{c(){d=n("meta"),v=h(),g=n("h1"),m=n("a"),b=n("span"),y(r.$$.fragment),p=h(),J=n("span"),Js=i("VisualBERT"),Bn=h(),L=n("h2"),me=n("a"),Io=n("span"),y(He.$$.fragment),Us=h(),Co=n("span"),js=i("Overview"),Jn=h(),fe=n("p"),zs=i("The VisualBERT model was proposed in "),Le=n("a"),Ws=i("VisualBERT: A Simple and Performant Baseline for Vision and Language"),Fs=i(` 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.`),Un=h(),Lt=n("p"),Is=i("The abstract from the paper is the following:"),jn=h(),Ot=n("p"),$o=n("em"),Cs=i(`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.`),zn=h(),Dt=n("p"),$s=i("Tips:"),Wn=h(),ge=n("ol"),Eo=n("li"),Oe=n("p"),Es=i("Most of the checkpoints provided work with the "),Kt=n("a"),Rs=i("VisualBertForPreTraining"),Zs=i(` configuration. Other
checkpoints provided are the fine-tuned checkpoints for down-stream tasks - VQA (\u2018visualbert-vqa\u2019), VCR
(\u2018visualbert-vcr\u2019), NLVR2 (\u2018visualbert-nlvr2\u2019). Hence, if you are not working on these downstream tasks, it is
recommended that you use the pretrained checkpoints.`),xs=h(),Ro=n("li"),Zo=n("p"),Xs=i(`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.`),Fn=h(),O=n("h2"),_e=n("a"),xo=n("span"),y(De.$$.fragment),Ns=h(),Xo=n("span"),As=i("Usage"),In=h(),eo=n("p"),Gs=i(`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.`),Cn=h(),to=n("p"),qs=i(`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.`),$n=h(),be=n("p"),Qs=i("The "),oo=n("a"),Ys=i("BertTokenizer"),Ps=i(` 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:`),En=h(),ve=n("ul"),No=n("li"),no=n("p"),Ke=n("a"),Ss=i("VisualBERT VQA demo notebook"),Hs=i(` : This notebook
contains an example on VisualBERT VQA.`),Ls=h(),Ao=n("li"),so=n("p"),et=n("a"),Os=i("Generate Embeddings for VisualBERT (Colab Notebook)"),Ds=i(` : This notebook contains
an example on how to generate visual embeddings.`),Rn=h(),ye=n("p"),Ks=i("The following example shows how to get the last hidden state using "),ao=n("a"),ea=i("VisualBertModel"),ta=i(":"),Zn=h(),y(tt.$$.fragment),xn=h(),A=n("p"),oa=i("This model was contributed by "),ot=n("a"),na=i("gchhablani"),sa=i(". The original code can be found "),nt=n("a"),aa=i("here"),ra=i("."),Xn=h(),D=n("h2"),Me=n("a"),Go=n("span"),y(st.$$.fragment),ia=h(),qo=n("span"),la=i("VisualBertConfig"),Nn=h(),C=n("div"),y(at.$$.fragment),da=h(),K=n("p"),ca=i("This is the configuration class to store the configuration of a "),ro=n("a"),pa=i("VisualBertModel"),ha=i(`. 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
`),rt=n("a"),ua=i("uclanlp/visualbert-vqa-coco-pre"),ma=i(" architecture."),fa=h(),ee=n("p"),ga=i("Configuration objects inherit from "),io=n("a"),_a=i("PretrainedConfig"),ba=i(` and can be used to control the model outputs. Read the
documentation from `),lo=n("a"),va=i("PretrainedConfig"),ya=i(" for more information."),Ma=h(),y(Te.$$.fragment),An=h(),te=n("h2"),we=n("a"),Qo=n("span"),y(it.$$.fragment),Ta=h(),Yo=n("span"),wa=i("VisualBertModel"),Gn=h(),U=n("div"),y(lt.$$.fragment),ka=h(),dt=n("p"),Va=i(`The bare VisualBert Model transformer outputting raw hidden-states without any specific head on top.
This model inherits from `),co=n("a"),Ba=i("PreTrainedModel"),Ja=i(`. 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.)`),Ua=h(),ct=n("p"),ja=i("This model is also a PyTorch "),pt=n("a"),za=i("torch.nn.Module"),Wa=i(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Fa=h(),ht=n("p"),Ia=i("The model can behave as an encoder (with only self-attention) following the architecture described in "),ut=n("a"),Ca=i(`Attention is
all you need`),$a=i(` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),Ea=h(),E=n("div"),y(mt.$$.fragment),Ra=h(),oe=n("p"),Za=i("The "),po=n("a"),xa=i("VisualBertModel"),Xa=i(" forward method, overrides the "),Po=n("code"),Na=i("__call__"),Aa=i(" special method."),Ga=h(),y(ke.$$.fragment),qa=h(),y(Ve.$$.fragment),qn=h(),ne=n("h2"),Be=n("a"),So=n("span"),y(ft.$$.fragment),Qa=h(),Ho=n("span"),Ya=i("VisualBertForPreTraining"),Qn=h(),j=n("div"),y(gt.$$.fragment),Pa=h(),se=n("p"),Sa=i("VisualBert Model with two heads on top as done during the pretraining: a "),Lo=n("code"),Ha=i("masked language modeling"),La=i(` head and a
`),Oo=n("code"),Oa=i("sentence-image prediction (classification)"),Da=i(" head."),Ka=h(),_t=n("p"),er=i("This model inherits from "),ho=n("a"),tr=i("PreTrainedModel"),or=i(`. 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.)`),nr=h(),bt=n("p"),sr=i("This model is also a PyTorch "),vt=n("a"),ar=i("torch.nn.Module"),rr=i(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ir=h(),R=n("div"),y(yt.$$.fragment),lr=h(),ae=n("p"),dr=i("The "),uo=n("a"),cr=i("VisualBertForPreTraining"),pr=i(" forward method, overrides the "),Do=n("code"),hr=i("__call__"),ur=i(" special method."),mr=h(),y(Je.$$.fragment),fr=h(),y(Ue.$$.fragment),Yn=h(),re=n("h2"),je=n("a"),Ko=n("span"),y(Mt.$$.fragment),gr=h(),en=n("span"),_r=i("VisualBertForQuestionAnswering"),Pn=h(),z=n("div"),y(Tt.$$.fragment),br=h(),tn=n("p"),vr=i(`VisualBert Model with a classification/regression head on top (a dropout and a linear layer on top of the pooled
output) for VQA.`),yr=h(),wt=n("p"),Mr=i("This model inherits from "),mo=n("a"),Tr=i("PreTrainedModel"),wr=i(`. 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.)`),kr=h(),kt=n("p"),Vr=i("This model is also a PyTorch "),Vt=n("a"),Br=i("torch.nn.Module"),Jr=i(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ur=h(),Z=n("div"),y(Bt.$$.fragment),jr=h(),ie=n("p"),zr=i("The "),fo=n("a"),Wr=i("VisualBertForQuestionAnswering"),Fr=i(" forward method, overrides the "),on=n("code"),Ir=i("__call__"),Cr=i(" special method."),$r=h(),y(ze.$$.fragment),Er=h(),y(We.$$.fragment),Sn=h(),le=n("h2"),Fe=n("a"),nn=n("span"),y(Jt.$$.fragment),Rr=h(),sn=n("span"),Zr=i("VisualBertForMultipleChoice"),Hn=h(),W=n("div"),y(Ut.$$.fragment),xr=h(),an=n("p"),Xr=i(`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.`),Nr=h(),jt=n("p"),Ar=i("This model inherits from "),go=n("a"),Gr=i("PreTrainedModel"),qr=i(`. 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.)`),Qr=h(),zt=n("p"),Yr=i("This model is also a PyTorch "),Wt=n("a"),Pr=i("torch.nn.Module"),Sr=i(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Hr=h(),x=n("div"),y(Ft.$$.fragment),Lr=h(),de=n("p"),Or=i("The "),_o=n("a"),Dr=i("VisualBertForMultipleChoice"),Kr=i(" forward method, overrides the "),rn=n("code"),ei=i("__call__"),ti=i(" special method."),oi=h(),y(Ie.$$.fragment),ni=h(),y(Ce.$$.fragment),Ln=h(),ce=n("h2"),$e=n("a"),ln=n("span"),y(It.$$.fragment),si=h(),dn=n("span"),ai=i("VisualBertForVisualReasoning"),On=h(),F=n("div"),y(Ct.$$.fragment),ri=h(),cn=n("p"),ii=i(`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.`),li=h(),$t=n("p"),di=i("This model inherits from "),bo=n("a"),ci=i("PreTrainedModel"),pi=i(`. 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.)`),hi=h(),Et=n("p"),ui=i("This model is also a PyTorch "),Rt=n("a"),mi=i("torch.nn.Module"),fi=i(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),gi=h(),X=n("div"),y(Zt.$$.fragment),_i=h(),pe=n("p"),bi=i("The "),vo=n("a"),vi=i("VisualBertForVisualReasoning"),yi=i(" forward method, overrides the "),pn=n("code"),Mi=i("__call__"),Ti=i(" special method."),wi=h(),y(Ee.$$.fragment),ki=h(),y(Re.$$.fragment),Dn=h(),he=n("h2"),Ze=n("a"),hn=n("span"),y(xt.$$.fragment),Vi=h(),un=n("span"),Bi=i("VisualBertForRegionToPhraseAlignment"),Kn=h(),I=n("div"),y(Xt.$$.fragment),Ji=h(),mn=n("p"),Ui=i(`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.`),ji=h(),Nt=n("p"),zi=i("This model inherits from "),yo=n("a"),Wi=i("PreTrainedModel"),Fi=i(`. 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.)`),Ii=h(),At=n("p"),Ci=i("This model is also a PyTorch "),Gt=n("a"),$i=i("torch.nn.Module"),Ei=i(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ri=h(),N=n("div"),y(qt.$$.fragment),Zi=h(),ue=n("p"),xi=i("The "),Mo=n("a"),Xi=i("VisualBertForRegionToPhraseAlignment"),Ni=i(" forward method, overrides the "),fn=n("code"),Ai=i("__call__"),Gi=i(" special method."),qi=h(),y(xe.$$.fragment),Qi=h(),y(Xe.$$.fragment),this.h()},l(t){const f=_d('[data-svelte="svelte-1phssyn"]',document.head);d=s(f,"META",{name:!0,content:!0}),f.forEach(o),v=u(t),g=s(t,"H1",{class:!0});var Qt=a(g);m=s(Qt,"A",{id:!0,class:!0,href:!0});var gn=a(m);b=s(gn,"SPAN",{});var _n=a(b);M(r.$$.fragment,_n),_n.forEach(o),gn.forEach(o),p=u(Qt),J=s(Qt,"SPAN",{});var bn=a(J);Js=l(bn,"VisualBERT"),bn.forEach(o),Qt.forEach(o),Bn=u(t),L=s(t,"H2",{class:!0});var Yt=a(L);me=s(Yt,"A",{id:!0,class:!0,href:!0});var vn=a(me);Io=s(vn,"SPAN",{});var yn=a(Io);M(He.$$.fragment,yn),yn.forEach(o),vn.forEach(o),Us=u(Yt),Co=s(Yt,"SPAN",{});var Mn=a(Co);js=l(Mn,"Overview"),Mn.forEach(o),Yt.forEach(o),Jn=u(t),fe=s(t,"P",{});var Pt=a(fe);zs=l(Pt,"The VisualBERT model was proposed in "),Le=s(Pt,"A",{href:!0,rel:!0});var Tn=a(Le);Ws=l(Tn,"VisualBERT: A Simple and Performant Baseline for Vision and Language"),Tn.forEach(o),Fs=l(Pt,` 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.`),Pt.forEach(o),Un=u(t),Lt=s(t,"P",{});var wn=a(Lt);Is=l(wn,"The abstract from the paper is the following:"),wn.forEach(o),jn=u(t),Ot=s(t,"P",{});var kn=a(Ot);$o=s(kn,"EM",{});var Vn=a($o);Cs=l(Vn,`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.`),Vn.forEach(o),kn.forEach(o),zn=u(t),Dt=s(t,"P",{});var Si=a(Dt);$s=l(Si,"Tips:"),Si.forEach(o),Wn=u(t),ge=s(t,"OL",{});var ts=a(ge);Eo=s(ts,"LI",{});var Hi=a(Eo);Oe=s(Hi,"P",{});var os=a(Oe);Es=l(os,"Most of the checkpoints provided work with the "),Kt=s(os,"A",{href:!0});var Li=a(Kt);Rs=l(Li,"VisualBertForPreTraining"),Li.forEach(o),Zs=l(os,` configuration. Other
checkpoints provided are the fine-tuned checkpoints for down-stream tasks - VQA (\u2018visualbert-vqa\u2019), VCR
(\u2018visualbert-vcr\u2019), NLVR2 (\u2018visualbert-nlvr2\u2019). Hence, if you are not working on these downstream tasks, it is
recommended that you use the pretrained checkpoints.`),os.forEach(o),Hi.forEach(o),xs=u(ts),Ro=s(ts,"LI",{});var Oi=a(Ro);Zo=s(Oi,"P",{});var Di=a(Zo);Xs=l(Di,`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.`),Di.forEach(o),Oi.forEach(o),ts.forEach(o),Fn=u(t),O=s(t,"H2",{class:!0});var ns=a(O);_e=s(ns,"A",{id:!0,class:!0,href:!0});var Ki=a(_e);xo=s(Ki,"SPAN",{});var el=a(xo);M(De.$$.fragment,el),el.forEach(o),Ki.forEach(o),Ns=u(ns),Xo=s(ns,"SPAN",{});var tl=a(Xo);As=l(tl,"Usage"),tl.forEach(o),ns.forEach(o),In=u(t),eo=s(t,"P",{});var ol=a(eo);Gs=l(ol,`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.`),ol.forEach(o),Cn=u(t),to=s(t,"P",{});var nl=a(to);qs=l(nl,`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.`),nl.forEach(o),$n=u(t),be=s(t,"P",{});var ss=a(be);Qs=l(ss,"The "),oo=s(ss,"A",{href:!0});var sl=a(oo);Ys=l(sl,"BertTokenizer"),sl.forEach(o),Ps=l(ss,` 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:`),ss.forEach(o),En=u(t),ve=s(t,"UL",{});var as=a(ve);No=s(as,"LI",{});var al=a(No);no=s(al,"P",{});var Yi=a(no);Ke=s(Yi,"A",{href:!0,rel:!0});var rl=a(Ke);Ss=l(rl,"VisualBERT VQA demo notebook"),rl.forEach(o),Hs=l(Yi,` : This notebook
contains an example on VisualBERT VQA.`),Yi.forEach(o),al.forEach(o),Ls=u(as),Ao=s(as,"LI",{});var il=a(Ao);so=s(il,"P",{});var Pi=a(so);et=s(Pi,"A",{href:!0,rel:!0});var ll=a(et);Os=l(ll,"Generate Embeddings for VisualBERT (Colab Notebook)"),ll.forEach(o),Ds=l(Pi,` : This notebook contains
an example on how to generate visual embeddings.`),Pi.forEach(o),il.forEach(o),as.forEach(o),Rn=u(t),ye=s(t,"P",{});var rs=a(ye);Ks=l(rs,"The following example shows how to get the last hidden state using "),ao=s(rs,"A",{href:!0});var dl=a(ao);ea=l(dl,"VisualBertModel"),dl.forEach(o),ta=l(rs,":"),rs.forEach(o),Zn=u(t),M(tt.$$.fragment,t),xn=u(t),A=s(t,"P",{});var To=a(A);oa=l(To,"This model was contributed by "),ot=s(To,"A",{href:!0,rel:!0});var cl=a(ot);na=l(cl,"gchhablani"),cl.forEach(o),sa=l(To,". The original code can be found "),nt=s(To,"A",{href:!0,rel:!0});var pl=a(nt);aa=l(pl,"here"),pl.forEach(o),ra=l(To,"."),To.forEach(o),Xn=u(t),D=s(t,"H2",{class:!0});var is=a(D);Me=s(is,"A",{id:!0,class:!0,href:!0});var hl=a(Me);Go=s(hl,"SPAN",{});var ul=a(Go);M(st.$$.fragment,ul),ul.forEach(o),hl.forEach(o),ia=u(is),qo=s(is,"SPAN",{});var ml=a(qo);la=l(ml,"VisualBertConfig"),ml.forEach(o),is.forEach(o),Nn=u(t),C=s(t,"DIV",{class:!0});var Ne=a(C);M(at.$$.fragment,Ne),da=u(Ne),K=s(Ne,"P",{});var wo=a(K);ca=l(wo,"This is the configuration class to store the configuration of a "),ro=s(wo,"A",{href:!0});var fl=a(ro);pa=l(fl,"VisualBertModel"),fl.forEach(o),ha=l(wo,`. 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
`),rt=s(wo,"A",{href:!0,rel:!0});var gl=a(rt);ua=l(gl,"uclanlp/visualbert-vqa-coco-pre"),gl.forEach(o),ma=l(wo," architecture."),wo.forEach(o),fa=u(Ne),ee=s(Ne,"P",{});var ko=a(ee);ga=l(ko,"Configuration objects inherit from "),io=s(ko,"A",{href:!0});var _l=a(io);_a=l(_l,"PretrainedConfig"),_l.forEach(o),ba=l(ko,` and can be used to control the model outputs. Read the
documentation from `),lo=s(ko,"A",{href:!0});var bl=a(lo);va=l(bl,"PretrainedConfig"),bl.forEach(o),ya=l(ko," for more information."),ko.forEach(o),Ma=u(Ne),M(Te.$$.fragment,Ne),Ne.forEach(o),An=u(t),te=s(t,"H2",{class:!0});var ls=a(te);we=s(ls,"A",{id:!0,class:!0,href:!0});var vl=a(we);Qo=s(vl,"SPAN",{});var yl=a(Qo);M(it.$$.fragment,yl),yl.forEach(o),vl.forEach(o),Ta=u(ls),Yo=s(ls,"SPAN",{});var Ml=a(Yo);wa=l(Ml,"VisualBertModel"),Ml.forEach(o),ls.forEach(o),Gn=u(t),U=s(t,"DIV",{class:!0});var G=a(U);M(lt.$$.fragment,G),ka=u(G),dt=s(G,"P",{});var ds=a(dt);Va=l(ds,`The bare VisualBert Model transformer outputting raw hidden-states without any specific head on top.
This model inherits from `),co=s(ds,"A",{href:!0});var Tl=a(co);Ba=l(Tl,"PreTrainedModel"),Tl.forEach(o),Ja=l(ds,`. 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.)`),ds.forEach(o),Ua=u(G),ct=s(G,"P",{});var cs=a(ct);ja=l(cs,"This model is also a PyTorch "),pt=s(cs,"A",{href:!0,rel:!0});var wl=a(pt);za=l(wl,"torch.nn.Module"),wl.forEach(o),Wa=l(cs,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),cs.forEach(o),Fa=u(G),ht=s(G,"P",{});var ps=a(ht);Ia=l(ps,"The model can behave as an encoder (with only self-attention) following the architecture described in "),ut=s(ps,"A",{href:!0,rel:!0});var kl=a(ut);Ca=l(kl,`Attention is
all you need`),kl.forEach(o),$a=l(ps,` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),ps.forEach(o),Ea=u(G),E=s(G,"DIV",{class:!0});var Ae=a(E);M(mt.$$.fragment,Ae),Ra=u(Ae),oe=s(Ae,"P",{});var Vo=a(oe);Za=l(Vo,"The "),po=s(Vo,"A",{href:!0});var Vl=a(po);xa=l(Vl,"VisualBertModel"),Vl.forEach(o),Xa=l(Vo," forward method, overrides the "),Po=s(Vo,"CODE",{});var Bl=a(Po);Na=l(Bl,"__call__"),Bl.forEach(o),Aa=l(Vo," special method."),Vo.forEach(o),Ga=u(Ae),M(ke.$$.fragment,Ae),qa=u(Ae),M(Ve.$$.fragment,Ae),Ae.forEach(o),G.forEach(o),qn=u(t),ne=s(t,"H2",{class:!0});var hs=a(ne);Be=s(hs,"A",{id:!0,class:!0,href:!0});var Jl=a(Be);So=s(Jl,"SPAN",{});var Ul=a(So);M(ft.$$.fragment,Ul),Ul.forEach(o),Jl.forEach(o),Qa=u(hs),Ho=s(hs,"SPAN",{});var jl=a(Ho);Ya=l(jl,"VisualBertForPreTraining"),jl.forEach(o),hs.forEach(o),Qn=u(t),j=s(t,"DIV",{class:!0});var q=a(j);M(gt.$$.fragment,q),Pa=u(q),se=s(q,"P",{});var Bo=a(se);Sa=l(Bo,"VisualBert Model with two heads on top as done during the pretraining: a "),Lo=s(Bo,"CODE",{});var zl=a(Lo);Ha=l(zl,"masked language modeling"),zl.forEach(o),La=l(Bo,` head and a
`),Oo=s(Bo,"CODE",{});var Wl=a(Oo);Oa=l(Wl,"sentence-image prediction (classification)"),Wl.forEach(o),Da=l(Bo," head."),Bo.forEach(o),Ka=u(q),_t=s(q,"P",{});var us=a(_t);er=l(us,"This model inherits from "),ho=s(us,"A",{href:!0});var Fl=a(ho);tr=l(Fl,"PreTrainedModel"),Fl.forEach(o),or=l(us,`. 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.)`),us.forEach(o),nr=u(q),bt=s(q,"P",{});var ms=a(bt);sr=l(ms,"This model is also a PyTorch "),vt=s(ms,"A",{href:!0,rel:!0});var Il=a(vt);ar=l(Il,"torch.nn.Module"),Il.forEach(o),rr=l(ms,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ms.forEach(o),ir=u(q),R=s(q,"DIV",{class:!0});var Ge=a(R);M(yt.$$.fragment,Ge),lr=u(Ge),ae=s(Ge,"P",{});var Jo=a(ae);dr=l(Jo,"The "),uo=s(Jo,"A",{href:!0});var Cl=a(uo);cr=l(Cl,"VisualBertForPreTraining"),Cl.forEach(o),pr=l(Jo," forward method, overrides the "),Do=s(Jo,"CODE",{});var $l=a(Do);hr=l($l,"__call__"),$l.forEach(o),ur=l(Jo," special method."),Jo.forEach(o),mr=u(Ge),M(Je.$$.fragment,Ge),fr=u(Ge),M(Ue.$$.fragment,Ge),Ge.forEach(o),q.forEach(o),Yn=u(t),re=s(t,"H2",{class:!0});var fs=a(re);je=s(fs,"A",{id:!0,class:!0,href:!0});var El=a(je);Ko=s(El,"SPAN",{});var Rl=a(Ko);M(Mt.$$.fragment,Rl),Rl.forEach(o),El.forEach(o),gr=u(fs),en=s(fs,"SPAN",{});var Zl=a(en);_r=l(Zl,"VisualBertForQuestionAnswering"),Zl.forEach(o),fs.forEach(o),Pn=u(t),z=s(t,"DIV",{class:!0});var Q=a(z);M(Tt.$$.fragment,Q),br=u(Q),tn=s(Q,"P",{});var xl=a(tn);vr=l(xl,`VisualBert Model with a classification/regression head on top (a dropout and a linear layer on top of the pooled
output) for VQA.`),xl.forEach(o),yr=u(Q),wt=s(Q,"P",{});var gs=a(wt);Mr=l(gs,"This model inherits from "),mo=s(gs,"A",{href:!0});var Xl=a(mo);Tr=l(Xl,"PreTrainedModel"),Xl.forEach(o),wr=l(gs,`. 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.)`),gs.forEach(o),kr=u(Q),kt=s(Q,"P",{});var _s=a(kt);Vr=l(_s,"This model is also a PyTorch "),Vt=s(_s,"A",{href:!0,rel:!0});var Nl=a(Vt);Br=l(Nl,"torch.nn.Module"),Nl.forEach(o),Jr=l(_s,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),_s.forEach(o),Ur=u(Q),Z=s(Q,"DIV",{class:!0});var qe=a(Z);M(Bt.$$.fragment,qe),jr=u(qe),ie=s(qe,"P",{});var Uo=a(ie);zr=l(Uo,"The "),fo=s(Uo,"A",{href:!0});var Al=a(fo);Wr=l(Al,"VisualBertForQuestionAnswering"),Al.forEach(o),Fr=l(Uo," forward method, overrides the "),on=s(Uo,"CODE",{});var Gl=a(on);Ir=l(Gl,"__call__"),Gl.forEach(o),Cr=l(Uo," special method."),Uo.forEach(o),$r=u(qe),M(ze.$$.fragment,qe),Er=u(qe),M(We.$$.fragment,qe),qe.forEach(o),Q.forEach(o),Sn=u(t),le=s(t,"H2",{class:!0});var bs=a(le);Fe=s(bs,"A",{id:!0,class:!0,href:!0});var ql=a(Fe);nn=s(ql,"SPAN",{});var Ql=a(nn);M(Jt.$$.fragment,Ql),Ql.forEach(o),ql.forEach(o),Rr=u(bs),sn=s(bs,"SPAN",{});var Yl=a(sn);Zr=l(Yl,"VisualBertForMultipleChoice"),Yl.forEach(o),bs.forEach(o),Hn=u(t),W=s(t,"DIV",{class:!0});var Y=a(W);M(Ut.$$.fragment,Y),xr=u(Y),an=s(Y,"P",{});var Pl=a(an);Xr=l(Pl,`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.`),Pl.forEach(o),Nr=u(Y),jt=s(Y,"P",{});var vs=a(jt);Ar=l(vs,"This model inherits from "),go=s(vs,"A",{href:!0});var Sl=a(go);Gr=l(Sl,"PreTrainedModel"),Sl.forEach(o),qr=l(vs,`. 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.)`),vs.forEach(o),Qr=u(Y),zt=s(Y,"P",{});var ys=a(zt);Yr=l(ys,"This model is also a PyTorch "),Wt=s(ys,"A",{href:!0,rel:!0});var Hl=a(Wt);Pr=l(Hl,"torch.nn.Module"),Hl.forEach(o),Sr=l(ys,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ys.forEach(o),Hr=u(Y),x=s(Y,"DIV",{class:!0});var Qe=a(x);M(Ft.$$.fragment,Qe),Lr=u(Qe),de=s(Qe,"P",{});var jo=a(de);Or=l(jo,"The "),_o=s(jo,"A",{href:!0});var Ll=a(_o);Dr=l(Ll,"VisualBertForMultipleChoice"),Ll.forEach(o),Kr=l(jo," forward method, overrides the "),rn=s(jo,"CODE",{});var Ol=a(rn);ei=l(Ol,"__call__"),Ol.forEach(o),ti=l(jo," special method."),jo.forEach(o),oi=u(Qe),M(Ie.$$.fragment,Qe),ni=u(Qe),M(Ce.$$.fragment,Qe),Qe.forEach(o),Y.forEach(o),Ln=u(t),ce=s(t,"H2",{class:!0});var Ms=a(ce);$e=s(Ms,"A",{id:!0,class:!0,href:!0});var Dl=a($e);ln=s(Dl,"SPAN",{});var Kl=a(ln);M(It.$$.fragment,Kl),Kl.forEach(o),Dl.forEach(o),si=u(Ms),dn=s(Ms,"SPAN",{});var ed=a(dn);ai=l(ed,"VisualBertForVisualReasoning"),ed.forEach(o),Ms.forEach(o),On=u(t),F=s(t,"DIV",{class:!0});var P=a(F);M(Ct.$$.fragment,P),ri=u(P),cn=s(P,"P",{});var td=a(cn);ii=l(td,`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.`),td.forEach(o),li=u(P),$t=s(P,"P",{});var Ts=a($t);di=l(Ts,"This model inherits from "),bo=s(Ts,"A",{href:!0});var od=a(bo);ci=l(od,"PreTrainedModel"),od.forEach(o),pi=l(Ts,`. 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.)`),Ts.forEach(o),hi=u(P),Et=s(P,"P",{});var ws=a(Et);ui=l(ws,"This model is also a PyTorch "),Rt=s(ws,"A",{href:!0,rel:!0});var nd=a(Rt);mi=l(nd,"torch.nn.Module"),nd.forEach(o),fi=l(ws,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ws.forEach(o),gi=u(P),X=s(P,"DIV",{class:!0});var Ye=a(X);M(Zt.$$.fragment,Ye),_i=u(Ye),pe=s(Ye,"P",{});var zo=a(pe);bi=l(zo,"The "),vo=s(zo,"A",{href:!0});var sd=a(vo);vi=l(sd,"VisualBertForVisualReasoning"),sd.forEach(o),yi=l(zo," forward method, overrides the "),pn=s(zo,"CODE",{});var ad=a(pn);Mi=l(ad,"__call__"),ad.forEach(o),Ti=l(zo," special method."),zo.forEach(o),wi=u(Ye),M(Ee.$$.fragment,Ye),ki=u(Ye),M(Re.$$.fragment,Ye),Ye.forEach(o),P.forEach(o),Dn=u(t),he=s(t,"H2",{class:!0});var ks=a(he);Ze=s(ks,"A",{id:!0,class:!0,href:!0});var rd=a(Ze);hn=s(rd,"SPAN",{});var id=a(hn);M(xt.$$.fragment,id),id.forEach(o),rd.forEach(o),Vi=u(ks),un=s(ks,"SPAN",{});var ld=a(un);Bi=l(ld,"VisualBertForRegionToPhraseAlignment"),ld.forEach(o),ks.forEach(o),Kn=u(t),I=s(t,"DIV",{class:!0});var S=a(I);M(Xt.$$.fragment,S),Ji=u(S),mn=s(S,"P",{});var dd=a(mn);Ui=l(dd,`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.`),dd.forEach(o),ji=u(S),Nt=s(S,"P",{});var Vs=a(Nt);zi=l(Vs,"This model inherits from "),yo=s(Vs,"A",{href:!0});var cd=a(yo);Wi=l(cd,"PreTrainedModel"),cd.forEach(o),Fi=l(Vs,`. 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.)`),Vs.forEach(o),Ii=u(S),At=s(S,"P",{});var Bs=a(At);Ci=l(Bs,"This model is also a PyTorch "),Gt=s(Bs,"A",{href:!0,rel:!0});var pd=a(Gt);$i=l(pd,"torch.nn.Module"),pd.forEach(o),Ei=l(Bs,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Bs.forEach(o),Ri=u(S),N=s(S,"DIV",{class:!0});var Pe=a(N);M(qt.$$.fragment,Pe),Zi=u(Pe),ue=s(Pe,"P",{});var Wo=a(ue);xi=l(Wo,"The "),Mo=s(Wo,"A",{href:!0});var hd=a(Mo);Xi=l(hd,"VisualBertForRegionToPhraseAlignment"),hd.forEach(o),Ni=l(Wo," forward method, overrides the "),fn=s(Wo,"CODE",{});var ud=a(fn);Ai=l(ud,"__call__"),ud.forEach(o),Gi=l(Wo," special method."),Wo.forEach(o),qi=u(Pe),M(xe.$$.fragment,Pe),Qi=u(Pe),M(Xe.$$.fragment,Pe),Pe.forEach(o),S.forEach(o),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(Id)),c(m,"id","visualbert"),c(m,"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"),c(m,"href","#visualbert"),c(g,"class","relative group"),c(me,"id","overview"),c(me,"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"),c(me,"href","#overview"),c(L,"class","relative group"),c(Le,"href","https://arxiv.org/pdf/1908.03557"),c(Le,"rel","nofollow"),c(Kt,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertForPreTraining"),c(_e,"id","usage"),c(_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"),c(_e,"href","#usage"),c(O,"class","relative group"),c(oo,"href","/docs/transformers/v4.30.0/en/model_doc/bert#transformers.BertTokenizer"),c(Ke,"href","https://github.com/huggingface/transformers/tree/main/examples/research_projects/visual_bert"),c(Ke,"rel","nofollow"),c(et,"href","https://colab.research.google.com/drive/1bLGxKdldwqnMVA5x4neY7-l_8fKGWQYI?usp=sharing"),c(et,"rel","nofollow"),c(ao,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertModel"),c(ot,"href","https://huggingface.co/gchhablani"),c(ot,"rel","nofollow"),c(nt,"href","https://github.com/uclanlp/visualbert"),c(nt,"rel","nofollow"),c(Me,"id","transformers.VisualBertConfig"),c(Me,"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"),c(Me,"href","#transformers.VisualBertConfig"),c(D,"class","relative group"),c(ro,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertModel"),c(rt,"href","https://huggingface.co/uclanlp/visualbert-vqa-coco-pre"),c(rt,"rel","nofollow"),c(io,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(lo,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(we,"id","transformers.VisualBertModel"),c(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"),c(we,"href","#transformers.VisualBertModel"),c(te,"class","relative group"),c(co,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(pt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(pt,"rel","nofollow"),c(ut,"href","https://arxiv.org/abs/1706.03762"),c(ut,"rel","nofollow"),c(po,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertModel"),c(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Be,"id","transformers.VisualBertForPreTraining"),c(Be,"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"),c(Be,"href","#transformers.VisualBertForPreTraining"),c(ne,"class","relative group"),c(ho,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(vt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(vt,"rel","nofollow"),c(uo,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertForPreTraining"),c(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(je,"id","transformers.VisualBertForQuestionAnswering"),c(je,"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"),c(je,"href","#transformers.VisualBertForQuestionAnswering"),c(re,"class","relative group"),c(mo,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(Vt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Vt,"rel","nofollow"),c(fo,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertForQuestionAnswering"),c(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Fe,"id","transformers.VisualBertForMultipleChoice"),c(Fe,"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"),c(Fe,"href","#transformers.VisualBertForMultipleChoice"),c(le,"class","relative group"),c(go,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(Wt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Wt,"rel","nofollow"),c(_o,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertForMultipleChoice"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c($e,"id","transformers.VisualBertForVisualReasoning"),c($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"),c($e,"href","#transformers.VisualBertForVisualReasoning"),c(ce,"class","relative group"),c(bo,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(Rt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Rt,"rel","nofollow"),c(vo,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertForVisualReasoning"),c(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ze,"id","transformers.VisualBertForRegionToPhraseAlignment"),c(Ze,"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"),c(Ze,"href","#transformers.VisualBertForRegionToPhraseAlignment"),c(he,"class","relative group"),c(yo,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(Gt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Gt,"rel","nofollow"),c(Mo,"href","/docs/transformers/v4.30.0/en/model_doc/visual_bert#transformers.VisualBertForRegionToPhraseAlignment"),c(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,d),_(t,v,f),_(t,g,f),e(g,m),e(m,b),T(r,b,null),e(g,p),e(g,J),e(J,Js),_(t,Bn,f),_(t,L,f),e(L,me),e(me,Io),T(He,Io,null),e(L,Us),e(L,Co),e(Co,js),_(t,Jn,f),_(t,fe,f),e(fe,zs),e(fe,Le),e(Le,Ws),e(fe,Fs),_(t,Un,f),_(t,Lt,f),e(Lt,Is),_(t,jn,f),_(t,Ot,f),e(Ot,$o),e($o,Cs),_(t,zn,f),_(t,Dt,f),e(Dt,$s),_(t,Wn,f),_(t,ge,f),e(ge,Eo),e(Eo,Oe),e(Oe,Es),e(Oe,Kt),e(Kt,Rs),e(Oe,Zs),e(ge,xs),e(ge,Ro),e(Ro,Zo),e(Zo,Xs),_(t,Fn,f),_(t,O,f),e(O,_e),e(_e,xo),T(De,xo,null),e(O,Ns),e(O,Xo),e(Xo,As),_(t,In,f),_(t,eo,f),e(eo,Gs),_(t,Cn,f),_(t,to,f),e(to,qs),_(t,$n,f),_(t,be,f),e(be,Qs),e(be,oo),e(oo,Ys),e(be,Ps),_(t,En,f),_(t,ve,f),e(ve,No),e(No,no),e(no,Ke),e(Ke,Ss),e(no,Hs),e(ve,Ls),e(ve,Ao),e(Ao,so),e(so,et),e(et,Os),e(so,Ds),_(t,Rn,f),_(t,ye,f),e(ye,Ks),e(ye,ao),e(ao,ea),e(ye,ta),_(t,Zn,f),T(tt,t,f),_(t,xn,f),_(t,A,f),e(A,oa),e(A,ot),e(ot,na),e(A,sa),e(A,nt),e(nt,aa),e(A,ra),_(t,Xn,f),_(t,D,f),e(D,Me),e(Me,Go),T(st,Go,null),e(D,ia),e(D,qo),e(qo,la),_(t,Nn,f),_(t,C,f),T(at,C,null),e(C,da),e(C,K),e(K,ca),e(K,ro),e(ro,pa),e(K,ha),e(K,rt),e(rt,ua),e(K,ma),e(C,fa),e(C,ee),e(ee,ga),e(ee,io),e(io,_a),e(ee,ba),e(ee,lo),e(lo,va),e(ee,ya),e(C,Ma),T(Te,C,null),_(t,An,f),_(t,te,f),e(te,we),e(we,Qo),T(it,Qo,null),e(te,Ta),e(te,Yo),e(Yo,wa),_(t,Gn,f),_(t,U,f),T(lt,U,null),e(U,ka),e(U,dt),e(dt,Va),e(dt,co),e(co,Ba),e(dt,Ja),e(U,Ua),e(U,ct),e(ct,ja),e(ct,pt),e(pt,za),e(ct,Wa),e(U,Fa),e(U,ht),e(ht,Ia),e(ht,ut),e(ut,Ca),e(ht,$a),e(U,Ea),e(U,E),T(mt,E,null),e(E,Ra),e(E,oe),e(oe,Za),e(oe,po),e(po,xa),e(oe,Xa),e(oe,Po),e(Po,Na),e(oe,Aa),e(E,Ga),T(ke,E,null),e(E,qa),T(Ve,E,null),_(t,qn,f),_(t,ne,f),e(ne,Be),e(Be,So),T(ft,So,null),e(ne,Qa),e(ne,Ho),e(Ho,Ya),_(t,Qn,f),_(t,j,f),T(gt,j,null),e(j,Pa),e(j,se),e(se,Sa),e(se,Lo),e(Lo,Ha),e(se,La),e(se,Oo),e(Oo,Oa),e(se,Da),e(j,Ka),e(j,_t),e(_t,er),e(_t,ho),e(ho,tr),e(_t,or),e(j,nr),e(j,bt),e(bt,sr),e(bt,vt),e(vt,ar),e(bt,rr),e(j,ir),e(j,R),T(yt,R,null),e(R,lr),e(R,ae),e(ae,dr),e(ae,uo),e(uo,cr),e(ae,pr),e(ae,Do),e(Do,hr),e(ae,ur),e(R,mr),T(Je,R,null),e(R,fr),T(Ue,R,null),_(t,Yn,f),_(t,re,f),e(re,je),e(je,Ko),T(Mt,Ko,null),e(re,gr),e(re,en),e(en,_r),_(t,Pn,f),_(t,z,f),T(Tt,z,null),e(z,br),e(z,tn),e(tn,vr),e(z,yr),e(z,wt),e(wt,Mr),e(wt,mo),e(mo,Tr),e(wt,wr),e(z,kr),e(z,kt),e(kt,Vr),e(kt,Vt),e(Vt,Br),e(kt,Jr),e(z,Ur),e(z,Z),T(Bt,Z,null),e(Z,jr),e(Z,ie),e(ie,zr),e(ie,fo),e(fo,Wr),e(ie,Fr),e(ie,on),e(on,Ir),e(ie,Cr),e(Z,$r),T(ze,Z,null),e(Z,Er),T(We,Z,null),_(t,Sn,f),_(t,le,f),e(le,Fe),e(Fe,nn),T(Jt,nn,null),e(le,Rr),e(le,sn),e(sn,Zr),_(t,Hn,f),_(t,W,f),T(Ut,W,null),e(W,xr),e(W,an),e(an,Xr),e(W,Nr),e(W,jt),e(jt,Ar),e(jt,go),e(go,Gr),e(jt,qr),e(W,Qr),e(W,zt),e(zt,Yr),e(zt,Wt),e(Wt,Pr),e(zt,Sr),e(W,Hr),e(W,x),T(Ft,x,null),e(x,Lr),e(x,de),e(de,Or),e(de,_o),e(_o,Dr),e(de,Kr),e(de,rn),e(rn,ei),e(de,ti),e(x,oi),T(Ie,x,null),e(x,ni),T(Ce,x,null),_(t,Ln,f),_(t,ce,f),e(ce,$e),e($e,ln),T(It,ln,null),e(ce,si),e(ce,dn),e(dn,ai),_(t,On,f),_(t,F,f),T(Ct,F,null),e(F,ri),e(F,cn),e(cn,ii),e(F,li),e(F,$t),e($t,di),e($t,bo),e(bo,ci),e($t,pi),e(F,hi),e(F,Et),e(Et,ui),e(Et,Rt),e(Rt,mi),e(Et,fi),e(F,gi),e(F,X),T(Zt,X,null),e(X,_i),e(X,pe),e(pe,bi),e(pe,vo),e(vo,vi),e(pe,yi),e(pe,pn),e(pn,Mi),e(pe,Ti),e(X,wi),T(Ee,X,null),e(X,ki),T(Re,X,null),_(t,Dn,f),_(t,he,f),e(he,Ze),e(Ze,hn),T(xt,hn,null),e(he,Vi),e(he,un),e(un,Bi),_(t,Kn,f),_(t,I,f),T(Xt,I,null),e(I,Ji),e(I,mn),e(mn,Ui),e(I,ji),e(I,Nt),e(Nt,zi),e(Nt,yo),e(yo,Wi),e(Nt,Fi),e(I,Ii),e(I,At),e(At,Ci),e(At,Gt),e(Gt,$i),e(At,Ei),e(I,Ri),e(I,N),T(qt,N,null),e(N,Zi),e(N,ue),e(ue,xi),e(ue,Mo),e(Mo,Xi),e(ue,Ni),e(ue,fn),e(fn,Ai),e(ue,Gi),e(N,qi),T(xe,N,null),e(N,Qi),T(Xe,N,null),es=!0},p(t,[f]){const Qt={};f&2&&(Qt.$$scope={dirty:f,ctx:t}),Te.$set(Qt);const gn={};f&2&&(gn.$$scope={dirty:f,ctx:t}),ke.$set(gn);const _n={};f&2&&(_n.$$scope={dirty:f,ctx:t}),Ve.$set(_n);const bn={};f&2&&(bn.$$scope={dirty:f,ctx:t}),Je.$set(bn);const Yt={};f&2&&(Yt.$$scope={dirty:f,ctx:t}),Ue.$set(Yt);const vn={};f&2&&(vn.$$scope={dirty:f,ctx:t}),ze.$set(vn);const yn={};f&2&&(yn.$$scope={dirty:f,ctx:t}),We.$set(yn);const Mn={};f&2&&(Mn.$$scope={dirty:f,ctx:t}),Ie.$set(Mn);const Pt={};f&2&&(Pt.$$scope={dirty:f,ctx:t}),Ce.$set(Pt);const Tn={};f&2&&(Tn.$$scope={dirty:f,ctx:t}),Ee.$set(Tn);const wn={};f&2&&(wn.$$scope={dirty:f,ctx:t}),Re.$set(wn);const kn={};f&2&&(kn.$$scope={dirty:f,ctx:t}),xe.$set(kn);const Vn={};f&2&&(Vn.$$scope={dirty:f,ctx:t}),Xe.$set(Vn)},i(t){es||(w(r.$$.fragment,t),w(He.$$.fragment,t),w(De.$$.fragment,t),w(tt.$$.fragment,t),w(st.$$.fragment,t),w(at.$$.fragment,t),w(Te.$$.fragment,t),w(it.$$.fragment,t),w(lt.$$.fragment,t),w(mt.$$.fragment,t),w(ke.$$.fragment,t),w(Ve.$$.fragment,t),w(ft.$$.fragment,t),w(gt.$$.fragment,t),w(yt.$$.fragment,t),w(Je.$$.fragment,t),w(Ue.$$.fragment,t),w(Mt.$$.fragment,t),w(Tt.$$.fragment,t),w(Bt.$$.fragment,t),w(ze.$$.fragment,t),w(We.$$.fragment,t),w(Jt.$$.fragment,t),w(Ut.$$.fragment,t),w(Ft.$$.fragment,t),w(Ie.$$.fragment,t),w(Ce.$$.fragment,t),w(It.$$.fragment,t),w(Ct.$$.fragment,t),w(Zt.$$.fragment,t),w(Ee.$$.fragment,t),w(Re.$$.fragment,t),w(xt.$$.fragment,t),w(Xt.$$.fragment,t),w(qt.$$.fragment,t),w(xe.$$.fragment,t),w(Xe.$$.fragment,t),es=!0)},o(t){k(r.$$.fragment,t),k(He.$$.fragment,t),k(De.$$.fragment,t),k(tt.$$.fragment,t),k(st.$$.fragment,t),k(at.$$.fragment,t),k(Te.$$.fragment,t),k(it.$$.fragment,t),k(lt.$$.fragment,t),k(mt.$$.fragment,t),k(ke.$$.fragment,t),k(Ve.$$.fragment,t),k(ft.$$.fragment,t),k(gt.$$.fragment,t),k(yt.$$.fragment,t),k(Je.$$.fragment,t),k(Ue.$$.fragment,t),k(Mt.$$.fragment,t),k(Tt.$$.fragment,t),k(Bt.$$.fragment,t),k(ze.$$.fragment,t),k(We.$$.fragment,t),k(Jt.$$.fragment,t),k(Ut.$$.fragment,t),k(Ft.$$.fragment,t),k(Ie.$$.fragment,t),k(Ce.$$.fragment,t),k(It.$$.fragment,t),k(Ct.$$.fragment,t),k(Zt.$$.fragment,t),k(Ee.$$.fragment,t),k(Re.$$.fragment,t),k(xt.$$.fragment,t),k(Xt.$$.fragment,t),k(qt.$$.fragment,t),k(xe.$$.fragment,t),k(Xe.$$.fragment,t),es=!1},d(t){o(d),t&&o(v),t&&o(g),V(r),t&&o(Bn),t&&o(L),V(He),t&&o(Jn),t&&o(fe),t&&o(Un),t&&o(Lt),t&&o(jn),t&&o(Ot),t&&o(zn),t&&o(Dt),t&&o(Wn),t&&o(ge),t&&o(Fn),t&&o(O),V(De),t&&o(In),t&&o(eo),t&&o(Cn),t&&o(to),t&&o($n),t&&o(be),t&&o(En),t&&o(ve),t&&o(Rn),t&&o(ye),t&&o(Zn),V(tt,t),t&&o(xn),t&&o(A),t&&o(Xn),t&&o(D),V(st),t&&o(Nn),t&&o(C),V(at),V(Te),t&&o(An),t&&o(te),V(it),t&&o(Gn),t&&o(U),V(lt),V(mt),V(ke),V(Ve),t&&o(qn),t&&o(ne),V(ft),t&&o(Qn),t&&o(j),V(gt),V(yt),V(Je),V(Ue),t&&o(Yn),t&&o(re),V(Mt),t&&o(Pn),t&&o(z),V(Tt),V(Bt),V(ze),V(We),t&&o(Sn),t&&o(le),V(Jt),t&&o(Hn),t&&o(W),V(Ut),V(Ft),V(Ie),V(Ce),t&&o(Ln),t&&o(ce),V(It),t&&o(On),t&&o(F),V(Ct),V(Zt),V(Ee),V(Re),t&&o(Dn),t&&o(he),V(xt),t&&o(Kn),t&&o(I),V(Xt),V(qt),V(xe),V(Xe)}}}const Id={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 Cd(B){return bd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nd extends md{constructor(d){super();fd(this,d,Cd,Fd,gd,{})}}export{Nd as default,Id as metadata};
