class_docstr: Data collator that will dynamically pad the inputs received.
  Args:
      processor ([`WhisperProcessor`])
          The processor used for processing the data.
      decoder_start_token_id (`int`)
          The begin-of-sentence of the decoder.
      forward_attention_mask (`bool`)
          Whether to return attention_mask.
class_docstr_tok: ["Data","collator","that","will","dynamically","pad","the","inputs","received",".","Args",":","processor","(","[","`","WhisperProcessor","`","]",")","The","processor","used","for","processing","the","data",".","decoder_start_token_id","(","`","int","`",")","The","begin-of-sentence","of","the","decoder",".","forward_attention_mask","(","`","bool","`",")","Whether","to","return","attention_mask","."]
code: def __call__(
      self, features: List[Dict[str, Union[List[int], torch.Tensor]]]
  ) -> Dict[str, torch.Tensor]:
      # split inputs and labels since they have to be of different lengths and need
      # different padding methods
      model_input_name = self.processor.model_input_names[0]
      input_features = [
          {model_input_name: feature[model_input_name]}
          for feature in features
      ]
      label_features = [
          {"input_ids": feature["labels"]} for feature in features
      ]
  
      batch = self.processor.feature_extractor.pad(
          input_features, return_tensors="pt"
      )
  
      if self.forward_attention_mask:
          batch["attention_mask"] = torch.LongTensor(
              [feature["attention_mask"] for feature in features]
          )
  
      labels_batch = self.processor.tokenizer.pad(
          label_features, return_tensors="pt"
      )
  
      # replace padding with -100 to ignore loss correctly
      labels = labels_batch["input_ids"].masked_fill(
          labels_batch.attention_mask.ne(1), -100
      )
  
      # if bos token is appended in previous tokenization step,
      # cut bos token here as it's append later anyways
      if (
          (labels[:, 0] == self.decoder_start_token_id)
          .all()
          .cpu()
          .item()
      ):
          labels = labels[:, 1:]
  
      batch["labels"] = labels
  
      return batch
  
file_path: transformers/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py
imports: import logging
  import os
  import sys
  import warnings
  from dataclasses import dataclass, field
  from typing import Any, Dict, List, Optional, Union
  import datasets
  import evaluate
  import torch
  from datasets import DatasetDict, load_dataset
  import transformers
  from transformers import AutoConfig, AutoFeatureExtractor, AutoModelForSpeechSeq2Seq, AutoProcessor, AutoTokenizer, HfArgumentParser, Seq2SeqTrainer, Seq2SeqTrainingArguments, set_seed
  from transformers.trainer_utils import get_last_checkpoint, is_main_process
  from transformers.utils import check_min_version, send_example_telemetry
  from transformers.utils.versions import require_version
label_desc: Use image node_id 1 for calling the DataCollatorSpeechSeq2SeqWithPadding obj's underlying member method code with example usage: obj.__call__(features) and returns: batch