docstr: Returns:
  
  Examples::
  
      >>> from transformers import ViTFeatureExtractor, ViTModel
      >>> from PIL import Image
      >>> import requests
  
      >>> url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
      >>> image = Image.open(requests.get(url, stream=True).raw)
  
      >>> feature_extractor = ViTFeatureExtractor.from_pretrained(
              'google/vit-base-patch16-224-in21k'
          )
      >>> model = ViTModel.from_pretrained('google/vit-base-patch16-224-in21k')
  
      >>> inputs = feature_extractor(images=image, return_tensors="pt")
      >>> outputs = model(**inputs)
      >>> last_hidden_states = outputs.last_hidden_state
docstr_tok: ["Returns",":","Examples",":",":",">",">",">","from","transformers","import","ViTFeatureExtractor",",","ViTModel",">",">",">","from","PIL","import","Image",">",">",">","import","requests",">",">",">","url","=","'http",":","\/\/images.cocodataset.org\/val2017\/000000039769.jpg'",">",">",">","image","=","Image.open","(","requests.get","(","url",",","stream=True",")",".raw",")",">",">",">","feature_extractor","=","ViTFeatureExtractor.from_pretrained","(","'google\/vit-base-patch16-224-in21k'",")",">",">",">","model","=","ViTModel.from_pretrained","(","'google\/vit-base-patch16-224-in21k","'",")",">",">",">","inputs","=","feature_extractor","(","images=image",",","return_tensors=","''","pt","''",")",">",">",">","outputs","=","model","(","*","*","inputs",")",">",">",">","last_hidden_states","=","outputs.last_hidden_state"]
code: def forward(
      self,
      input_values=None,
      attention_mask=None,
      head_mask=None,
      output_attentions=None,
      output_hidden_states=None,
      return_dict=None,
  ):
      r"""
      Returns:
  
      Examples::
  
          >>> from transformers import ViTFeatureExtractor, ViTModel
          >>> from PIL import Image
          >>> import requests
  
          >>> url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
          >>> image = Image.open(requests.get(url, stream=True).raw)
  
          >>> feature_extractor = ViTFeatureExtractor.from_pretrained(
                  'google/vit-base-patch16-224-in21k'
              )
          >>> model = ViTModel.from_pretrained('google/vit-base-patch16-224-in21k')
  
          >>> inputs = feature_extractor(images=image, return_tensors="pt")
          >>> outputs = model(**inputs)
          >>> last_hidden_states = outputs.last_hidden_state
      """
      output_attentions = (
          output_attentions
          if output_attentions is not None
          else self.config.output_attentions
      )
      output_hidden_states = (
          output_hidden_states
          if output_hidden_states is not None
          else self.config.output_hidden_states
      )
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      if input_values is None:
          raise ValueError("You have to specify input_values")
  
      # Prepare head mask if needed
      # 1.0 in head_mask indicate we keep the head
      # attention_probs has shape bsz x n_heads x N x N
      # input head_mask has shape [num_heads] or [num_hidden_layers x num_heads]
      # and head_mask is converted to shape
      # [num_hidden_layers x batch x num_heads x seq_length x seq_length]
      head_mask = self.get_head_mask(
          head_mask, self.config.num_hidden_layers
      )
  
      do_patch_embeddings = getattr(
          self.config, "do_patch_embeddings", True
      )
      embedding_output = (
          self.embeddings(input_values)
          if do_patch_embeddings
          else input_values
      )
  
      batch_size, seq_length, _ = embedding_output.shape
      device = embedding_output.device
  
      if attention_mask is None:
          attention_mask = torch.ones(
              ((batch_size, seq_length)), device=device
          )
  
      # We can provide a self-attention mask of dimensions
      # [batch_size, from_seq_length, to_seq_length]
      # ourselves in which case we just need to make it broadcastable to all heads.
      extended_attention_mask: torch.Tensor = (
          self.get_extended_attention_mask(
              attention_mask, (batch_size, seq_length), device
          )
      )
  
      encoder_outputs = self.encoder(
          embedding_output,
          attention_mask=extended_attention_mask,
          head_mask=head_mask,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
      )
      sequence_output = encoder_outputs[0]
      sequence_output = self.layernorm(sequence_output)
      pooled_output = (
          self.pooler(sequence_output)
          if self.pooler is not None
          else None
      )
  
      if not return_dict:
          return (sequence_output, pooled_output) + encoder_outputs[1:]
  
      return vit.BaseModelOutputWithPooling(
          last_hidden_state=sequence_output,
          pooler_output=pooled_output,
          hidden_states=encoder_outputs.hidden_states,
          attentions=encoder_outputs.attentions,
      )
  
imports: from collections import namedtuple
  from dataclasses import asdict, dataclass
  import torch
  from mmf.utils.general import retry_n
  from omegaconf import OmegaConf
  from packaging import version
  from torch import nn
label_desc: Use image node_id 4 for calling the ViTModel obj's underlying member method code with example usage: obj.forward(input_values, attention_mask, head_mask, output_attentions, output_hidden_states, return_dict) and returns: vit, unknown