docstr: labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
      Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
      config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
      `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
docstr_tok: ["labels","(","`","torch.LongTensor","`","of","shape","`","(","batch_size",",",")","`",",","*","optional","*",")",":","Labels","for","computing","the","image","classification\/regression","loss",".","Indices","should","be","in","`","[","0",",","...",",","config.num_labels","-","1","]","`",".","If","`","config.num_labels","==","1","`","a","regression","loss","is","computed","(","Mean-Square","loss",")",",","If","`","config.num_labels",">","1","`","a","classification","loss","is","computed","(","Cross-Entropy",")","."]
code: def forward(
      self,
      pixel_values: Optional[torch.Tensor] = None,
      head_mask: Optional[torch.Tensor] = None,
      labels: Optional[torch.Tensor] = None,
      output_attentions: Optional[bool] = None,
      output_hidden_states: Optional[bool] = None,
      interpolate_pos_encoding: Optional[bool] = None,
      return_dict: Optional[bool] = None,
  ) -> Union[tuple, ImageClassifierOutput]:
      r"""
      labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
          Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
          config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
          `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
      """
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      outputs = self.vit(
          pixel_values,
          head_mask=head_mask,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          interpolate_pos_encoding=interpolate_pos_encoding,
          return_dict=return_dict,
      )
  
      sequence_output = outputs[0]
  
      logits = self.classifier(sequence_output[:, 0, :])
  
      loss = None
      if labels is not None:
          # move labels to correct device to enable model parallelism
          labels = labels.to(logits.device)
          if self.config.problem_type is None:
              if self.num_labels == 1:
                  self.config.problem_type = "regression"
              elif self.num_labels > 1 and (
                  labels.dtype == torch.long
                  or labels.dtype == torch.int
              ):
                  self.config.problem_type = (
                      "single_label_classification"
                  )
              else:
                  self.config.problem_type = (
                      "multi_label_classification"
                  )
  
          if self.config.problem_type == "regression":
              loss_fct = MSELoss()
              if self.num_labels == 1:
                  loss = loss_fct(logits.squeeze(), labels.squeeze())
              else:
                  loss = loss_fct(logits, labels)
          elif (
              self.config.problem_type == "single_label_classification"
          ):
              loss_fct = CrossEntropyLoss()
              loss = loss_fct(
                  logits.view(-1, self.num_labels), labels.view(-1)
              )
          elif self.config.problem_type == "multi_label_classification":
              loss_fct = BCEWithLogitsLoss()
              loss = loss_fct(logits, labels)
  
      if not return_dict:
          output = (logits,) + outputs[1:]
          return ((loss,) + output) if loss is not None else output
  
      return ImageClassifierOutput(
          loss=loss,
          logits=logits,
          hidden_states=outputs.hidden_states,
          attentions=outputs.attentions,
      )
  
imports: import collections.abc
  import math
  from typing import Dict, List, Optional, Set, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, ImageClassifierOutput
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from ..auto import AutoBackbone
  from .configuration_vit_hybrid import ViTHybridConfig
label_desc: Use image node_id 2 for calling the ViTHybridForImageClassification obj's underlying member method code with example usage: obj.forward(pixel_values, head_mask, labels, output_attentions, output_hidden_states, interpolate_pos_encoding, return_dict) and returns: ImageClassifierOutput, unknown