docstr: Perform a training step on a batch of inputs.
  
  Subclass and override to inject custom behavior.
  
  Args:
      model (:obj:`nn.Module`):
          The model to train.
      inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
          The inputs and targets of the model.
  
          The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
          argument :obj:`labels`. Check your model's documentation for all accepted arguments.
  
  Return:
      :obj:`torch.Tensor`: The tensor with training loss on this batch.
docstr_tok: ["Perform","a","training","step","on","a","batch","of","inputs",".","Subclass","and","override","to","inject","custom","behavior",".","Args",":","model","(",":","obj",":","`","nn.Module","`",")",":","The","model","to","train",".","inputs","(",":","obj",":","`","Dict","[","str",",","Union","[","torch.Tensor",",","Any","]","]","`",")",":","The","inputs","and","targets","of","the","model",".","The","dictionary","will","be","unpacked","before","being","fed","to","the","model",".","Most","models","expect","the","targets","under","the","argument",":","obj",":","`","labels","`",".","Check","your","model","'s","documentation","for","all","accepted","arguments",".","Return",":",":","obj",":","`","torch.Tensor","`",":","The","tensor","with","training","loss","on","this","batch","."]
code: def training_step(
      self,
      model: nn.Module,
      inputs: Dict[str, Union[torch.Tensor, Any]],
  ) -> torch.Tensor:
      """
      Perform a training step on a batch of inputs.
  
      Subclass and override to inject custom behavior.
  
      Args:
          model (:obj:`nn.Module`):
              The model to train.
          inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
              The inputs and targets of the model.
  
              The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
              argument :obj:`labels`. Check your model's documentation for all accepted arguments.
  
      Return:
          :obj:`torch.Tensor`: The tensor with training loss on this batch.
      """
  
      model.train()
      inputs = self._prepare_inputs(inputs)
  
      if self.use_amp:
          with autocast():
              loss = self.compute_loss(model, inputs)
      else:
          loss = self.compute_loss(model, inputs)
  
      if self.args.n_gpu > 1:
          if model.module.config.ctc_loss_reduction == "mean":
              loss = loss.mean()
          elif model.module.config.ctc_loss_reduction == "sum":
              loss = loss.sum() / (inputs["labels"] >= 0).sum()
          else:
              raise ValueError(
                  f"{model.config.ctc_loss_reduction} is not valid. Choose one of ['mean', 'sum']"
              )
  
      if self.args.gradient_accumulation_steps > 1:
          loss = loss / self.args.gradient_accumulation_steps
  
      if self.use_amp:
          self.scaler.scale(loss).backward()
      elif self.use_apex:
          with amp.scale_loss(loss, self.optimizer) as scaled_loss:
              scaled_loss.backward()
      elif self.deepspeed:
          self.deepspeed.backward(loss)
      else:
          loss.backward()
  
      return loss.detach()
  
imports: import logging
  import pathlib
  import re
  import sys
  from dataclasses import dataclass, field
  from typing import Any, Callable, Dict, List, Optional, Set, Union
  import datasets
  import librosa
  import numpy
  import torch
  from lang_trans import arabic
  from packaging import version
  from torch import nn
  from transformers import HfArgumentParser, Trainer, TrainingArguments, Wav2Vec2CTCTokenizer, Wav2Vec2FeatureExtractor, Wav2Vec2ForCTC, Wav2Vec2Processor, is_apex_available, trainer_utils
label_desc: Use image node_id 1 for calling the CTCTrainer obj's underlying member method code with example usage: obj.training_step(model, inputs) and returns: loss