docstr: Returns:
  
  Example:
   ```python
   >>> import torch
   >>> from transformers import WhisperFeatureExtractor, WhisperModel
   >>> from datasets import load_dataset
  
   >>> model = WhisperModel.from_pretrained("openai/whisper-base")
   >>> feature_extractor = WhisperFeatureExtractor.from_pretrained("openai/whisper-base")
   >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
   >>> inputs = feature_extractor(ds[0]["audio"]["array"], return_tensors="pt")
   >>> input_features = inputs.input_features
   >>> decoder_input_ids = torch.tensor([[1, 1]]) * model.config.decoder_start_token_id
   >>> last_hidden_state = model(input_features, decoder_input_ids=decoder_input_ids).last_hidden_state
   >>> list(last_hidden_state.shape)
   [1, 2, 512]
   ```
docstr_tok: ["Returns",":","Example",":","``","`","python",">",">",">","import","torch",">",">",">","from","transformers","import","WhisperFeatureExtractor",",","WhisperModel",">",">",">","from","datasets","import","load_dataset",">",">",">","model","=","WhisperModel.from_pretrained","(","``","openai\/whisper-base","''",")",">",">",">","feature_extractor","=","WhisperFeatureExtractor.from_pretrained","(","``","openai\/whisper-base","''",")",">",">",">","ds","=","load_dataset","(","``","hf-internal-testing\/librispeech_asr_dummy","''",",","``","clean","''",",","split=","''","validation","''",")",">",">",">","inputs","=","feature_extractor","(","ds","[","0","]","[","``","audio","''","]","[","``","array","''","]",",","return_tensors=","''","pt","''",")",">",">",">","input_features","=","inputs.input_features",">",">",">","decoder_input_ids","=","torch.tensor","(","[","[","1",",","1","]","]",")","*","model.config.decoder_start_token_id",">",">",">","last_hidden_state","=","model","(","input_features",",","decoder_input_ids=decoder_input_ids",")",".last_hidden_state",">",">",">","list","(","last_hidden_state.shape",")","[","1",",","2",",","512","]","``","`"]
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,
      use_cache=None,
      output_attentions=None,
      output_hidden_states=None,
      return_dict=None,
  ):
      r"""
      Returns:
  
      Example:
       ```python
       >>> import torch
       >>> from transformers import WhisperFeatureExtractor, WhisperModel
       >>> from datasets import load_dataset
  
       >>> model = WhisperModel.from_pretrained("openai/whisper-base")
       >>> feature_extractor = WhisperFeatureExtractor.from_pretrained("openai/whisper-base")
       >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
       >>> inputs = feature_extractor(ds[0]["audio"]["array"], return_tensors="pt")
       >>> input_features = inputs.input_features
       >>> decoder_input_ids = torch.tensor([[1, 1]]) * model.config.decoder_start_token_id
       >>> last_hidden_state = model(input_features, decoder_input_ids=decoder_input_ids).last_hidden_state
       >>> list(last_hidden_state.shape)
       [1, 2, 512]
       ```"""
      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
      )
      use_cache = (
          use_cache if use_cache is not None else self.config.use_cache
      )
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      if encoder_outputs is None:
          encoder_outputs = self.encoder(
              input_features,
              head_mask=head_mask,
              output_attentions=output_attentions,
              output_hidden_states=output_hidden_states,
              return_dict=return_dict,
          )
      # If the user passed a tuple for encoder_outputs, we wrap it in a BaseModelOutput when return_dict=True
      elif return_dict and not isinstance(
          encoder_outputs, BaseModelOutput
      ):
          encoder_outputs = BaseModelOutput(
              last_hidden_state=encoder_outputs[0],
              hidden_states=encoder_outputs[1]
              if len(encoder_outputs) > 1
              else None,
              attentions=encoder_outputs[2]
              if len(encoder_outputs) > 2
              else None,
          )
  
      # decoder outputs consists of (dec_features, past_key_value, dec_hidden, dec_attn)
      decoder_outputs = self.decoder(
          input_ids=decoder_input_ids,
          attention_mask=decoder_attention_mask,
          encoder_hidden_states=encoder_outputs[0],
          head_mask=decoder_head_mask,
          cross_attn_head_mask=cross_attn_head_mask,
          past_key_values=past_key_values,
          inputs_embeds=decoder_inputs_embeds,
          use_cache=use_cache,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
      )
  
      if not return_dict:
          return decoder_outputs + encoder_outputs
  
      return Seq2SeqModelOutput(
          last_hidden_state=decoder_outputs.last_hidden_state,
          past_key_values=decoder_outputs.past_key_values,
          decoder_hidden_states=decoder_outputs.hidden_states,
          decoder_attentions=decoder_outputs.attentions,
          cross_attentions=decoder_outputs.cross_attentions,
          encoder_last_hidden_state=encoder_outputs.last_hidden_state,
          encoder_hidden_states=encoder_outputs.hidden_states,
          encoder_attentions=encoder_outputs.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 7 for calling the WhisperModel 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, use_cache, output_attentions, output_hidden_states, return_dict) and returns: Seq2SeqModelOutput, unknown