docstr: labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
      Labels for computing the language modeling loss. Indices should either be in `[0, ..., config.vocab_size]`
      or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored (masked), the loss is
      only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
  
  Returns:
  
  Example:
  
  ```python
  >>> import torch
  >>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
  >>> from datasets import load_dataset
  
  >>> processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
  >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
  
  >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
  
  >>> inputs = processor(ds[0]["audio"]["array"], return_tensors="pt")
  >>> input_features = inputs.input_features
  
  >>> generated_ids = model.generate(inputs=input_features)
  
  >>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
  >>> transcription
  ' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.'
  ```
docstr_tok: ["labels","(","`","torch.LongTensor","`","of","shape","`","(","batch_size",",","sequence_length",")","`",",","*","optional","*",")",":","Labels","for","computing","the","language","modeling","loss",".","Indices","should","either","be","in","`","[","0",",","...",",","config.vocab_size","]","`","or","-100","(","see","`","input_ids","`","docstring",")",".","Tokens","with","indices","set","to","`","-100","`","are","ignored","(","masked",")",",","the","loss","is","only","computed","for","the","tokens","with","labels","in","`","[","0",",","...",",","config.vocab_size","]","`",".","Returns",":","Example",":","``","`","python",">",">",">","import","torch",">",">",">","from","transformers","import","WhisperProcessor",",","WhisperForConditionalGeneration",">",">",">","from","datasets","import","load_dataset",">",">",">","processor","=","WhisperProcessor.from_pretrained","(","``","openai\/whisper-tiny.en","''",")",">",">",">","model","=","WhisperForConditionalGeneration.from_pretrained","(","``","openai\/whisper-tiny.en","''",")",">",">",">","ds","=","load_dataset","(","``","hf-internal-testing\/librispeech_asr_dummy","''",",","``","clean","''",",","split=","''","validation","''",")",">",">",">","inputs","=","processor","(","ds","[","0","]","[","``","audio","''","]","[","``","array","''","]",",","return_tensors=","''","pt","''",")",">",">",">","input_features","=","inputs.input_features",">",">",">","generated_ids","=","model.generate","(","inputs=input_features",")",">",">",">","transcription","=","processor.batch_decode","(","generated_ids",",","skip_special_tokens=True",")","[","0","]",">",">",">","transcription","'","Mr.","Quilter","is","the","apostle","of","the","middle","classes",",","and","we","are","glad","to","welcome","his","gospel",".","'","``","`"]
code: def forward(
      self,
      input_features=None,
      decoder_input_ids=None,
      decoder_attention_mask=None,
      head_mask=None,
      decoder_head_mask=None,
      cross_attn_head_mask=None,
      encoder_outputs=None,
      past_key_values=None,
      decoder_inputs_embeds=None,
      labels=None,
      use_cache=None,
      output_attentions=None,
      output_hidden_states=None,
      return_dict=None,
  ):
      r"""
      labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
          Labels for computing the language modeling loss. Indices should either be in `[0, ..., config.vocab_size]`
          or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored (masked), the loss is
          only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
  
      Returns:
  
      Example:
  
      ```python
      >>> import torch
      >>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
      >>> from datasets import load_dataset
  
      >>> processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
      >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
  
      >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
  
      >>> inputs = processor(ds[0]["audio"]["array"], return_tensors="pt")
      >>> input_features = inputs.input_features
  
      >>> generated_ids = model.generate(inputs=input_features)
  
      >>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
      >>> transcription
      ' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.'
      ```"""
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      if labels is not None:
          if (
              decoder_input_ids is None
              and decoder_inputs_embeds is None
          ):
              decoder_input_ids = shift_tokens_right(
                  labels,
                  self.config.pad_token_id,
                  self.config.decoder_start_token_id,
              )
  
      outputs = self.model(
          input_features,
          decoder_input_ids=decoder_input_ids,
          encoder_outputs=encoder_outputs,
          decoder_attention_mask=decoder_attention_mask,
          head_mask=head_mask,
          decoder_head_mask=decoder_head_mask,
          cross_attn_head_mask=cross_attn_head_mask,
          past_key_values=past_key_values,
          decoder_inputs_embeds=decoder_inputs_embeds,
          use_cache=use_cache,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
      )
      lm_logits = self.proj_out(outputs[0])
  
      loss = None
      if labels is not None:
          loss_fct = CrossEntropyLoss()
          loss = loss_fct(
              lm_logits.view(-1, self.config.vocab_size),
              labels.view(-1),
          )
  
      if not return_dict:
          output = (lm_logits,) + outputs[1:]
          return ((loss,) + output) if loss is not None else output
  
      return Seq2SeqLMOutput(
          loss=loss,
          logits=lm_logits,
          past_key_values=outputs.past_key_values,
          decoder_hidden_states=outputs.decoder_hidden_states,
          decoder_attentions=outputs.decoder_attentions,
          cross_attentions=outputs.cross_attentions,
          encoder_last_hidden_state=outputs.encoder_last_hidden_state,
          encoder_hidden_states=outputs.encoder_hidden_states,
          encoder_attentions=outputs.encoder_attentions,
      )
  
imports: import math
  import random
  from typing import Optional, Tuple
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_whisper import WhisperConfig
label_desc: Use image node_id 8 for calling the WhisperForConditionalGeneration obj's underlying member method code with example usage: obj.forward(input_features, decoder_input_ids, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, past_key_values, decoder_inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict) and returns: Seq2SeqLMOutput, unknown