class_docstr: Base class for encoder-decoder models used for self-supervised encoder pre-training
class_docstr_tok: ["Base","class","for","encoder-decoder","models","used","for","self-supervised","encoder","pre-training"]
docstr: Forward pass through all decoders and calculate corresponding losses.
  Args:
      spectrograms: Processed spectrograms of shape [B, D, T].
      spec_masks: Masks applied to spectrograms of shape [B, D, T].
      encoded: The encoded features tensor of shape [B, D, T].
      encoded_len: The lengths of the acoustic sequence after propagation through the encoder, of shape [B].
      targets: Optional target labels of shape [B, T]
      target_lengths: Optional target label lengths of shape [B]
  
  Returns:
      A tuple of 2 elements -
      1) Total sum of losses weighted by corresponding loss_alphas
      2) Dictionary of unweighted losses
docstr_tok: ["Forward","pass","through","all","decoders","and","calculate","corresponding","losses",".","Args",":","spectrograms",":","Processed","spectrograms","of","shape","[","B",",","D",",","T","]",".","spec_masks",":","Masks","applied","to","spectrograms","of","shape","[","B",",","D",",","T","]",".","encoded",":","The","encoded","features","tensor","of","shape","[","B",",","D",",","T","]",".","encoded_len",":","The","lengths","of","the","acoustic","sequence","after","propagation","through","the","encoder",",","of","shape","[","B","]",".","targets",":","Optional","target","labels","of","shape","[","B",",","T","]","target_lengths",":","Optional","target","label","lengths","of","shape","[","B","]","Returns",":","A","tuple","of","2","elements","-","1",")","Total","sum","of","losses","weighted","by","corresponding","loss_alphas","2",")","Dictionary","of","unweighted","losses"]
code: def decoder_loss_step(
      self,
      spectrograms,
      spec_masks,
      encoded,
      encoded_len,
      targets=None,
      target_lengths=None,
  ):
      """
      Forward pass through all decoders and calculate corresponding losses.
      Args:
          spectrograms: Processed spectrograms of shape [B, D, T].
          spec_masks: Masks applied to spectrograms of shape [B, D, T].
          encoded: The encoded features tensor of shape [B, D, T].
          encoded_len: The lengths of the acoustic sequence after propagation through the encoder, of shape [B].
          targets: Optional target labels of shape [B, T]
          target_lengths: Optional target label lengths of shape [B]
  
      Returns:
          A tuple of 2 elements -
          1) Total sum of losses weighted by corresponding loss_alphas
          2) Dictionary of unweighted losses
      """
      loss_val_dict = {}
  
      if self.decoder_losses is None:
          if (
              hasattr(self.decoder_ssl, "needs_labels")
              and self.decoder_ssl.needs_labels
          ):
              outputs = self.decoder_ssl(
                  encoder_output=encoded,
                  targets=targets,
                  target_lengths=target_lengths,
              )
          else:
              outputs = self.decoder_ssl(encoder_output=encoded)
          if self.loss.needs_labels:
              loss_value = self.loss(
                  spec_masks=spec_masks,
                  decoder_outputs=outputs,
                  targets=targets,
                  decoder_lengths=encoded_len,
                  target_lengths=target_lengths,
              )
          else:
              loss_value = self.loss(
                  spectrograms=spectrograms,
                  spec_masks=spec_masks,
                  decoder_outputs=outputs,
              )
      else:
          loss_value = encoded.new_zeros(1)
          outputs = {}
          registry = self.get_module_registry(self.encoder)
  
          for dec_loss_name, dec_loss in self.decoder_losses.items():
              # loop through decoders and corresponding losses
              if not self.decoder_losses_active[dec_loss_name]:
                  continue
  
              if self.output_from_layer[dec_loss_name] is None:
                  dec_input = encoded
              else:
                  # extract output from specified layer using AccessMixin registry
                  dec_input = registry[
                      self.output_from_layer[dec_loss_name]
                  ]["encoder"][-1]
              if self.transpose_encoded[dec_loss_name]:
                  dec_input = dec_input.transpose(-2, -1)
  
              if self.targets_from_loss[dec_loss_name] is not None:
                  # extract targets from specified loss
                  target_loss = self.targets_from_loss[dec_loss_name]
                  targets = self.decoder_losses[target_loss][
                      "loss"
                  ].target_ids
                  target_lengths = self.decoder_losses[target_loss][
                      "loss"
                  ].target_lengths
                  if target_lengths is None:
                      target_lengths = encoded_len
  
              if (
                  hasattr(dec_loss["decoder"], "needs_labels")
                  and dec_loss["decoder"].needs_labels
              ):
                  # if we are using a decoder which needs labels, provide them
                  outputs[dec_loss_name] = dec_loss["decoder"](
                      encoder_output=dec_input,
                      targets=targets,
                      target_lengths=target_lengths,
                  )
              else:
                  outputs[dec_loss_name] = dec_loss["decoder"](
                      encoder_output=dec_input
                  )
  
              current_loss = dec_loss["loss"]
              if current_loss.needs_labels:
                  # if we are using a loss which needs labels, provide them
                  current_loss_value = current_loss(
                      spec_masks=spec_masks,
                      decoder_outputs=outputs[dec_loss_name],
                      targets=targets,
                      decoder_lengths=encoded_len,
                      target_lengths=target_lengths,
                  )
              else:
                  current_loss_value = current_loss(
                      spectrograms=spectrograms,
                      spec_masks=spec_masks,
                      decoder_outputs=outputs[dec_loss_name],
                      decoder_lengths=encoded_len,
                  )
              loss_value = (
                  loss_value
                  + current_loss_value * self.loss_alphas[dec_loss_name]
              )
              loss_val_dict[dec_loss_name] = current_loss_value
  
      return loss_value, loss_val_dict
  
imports: from math import ceil
  from typing import Dict, List, Optional, Union
  import torch
  import torch.nn
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from nemo.collections.asr.data import audio_to_text_dataset
  from nemo.collections.asr.data.audio_to_text_dali import DALIOutputs
  from nemo.collections.asr.data.audio_to_text_lhotse import LhotseSpeechToTextBpeDataset
  from nemo.collections.asr.parts.mixins import ASRModuleMixin
  from nemo.collections.asr.parts.preprocessing.perturb import process_augmentations
  from nemo.collections.common.data.lhotse import get_lhotse_dataloader_from_config
  from nemo.collections.common.parts.preprocessing.parsers import make_parser
  from nemo.core.classes import ModelPT
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.classes.mixins import AccessMixin, set_access_cfg
  from nemo.core.neural_types import AcousticEncodedRepresentation, AudioSignal, LabelsType, LengthsType, NeuralType, SpectrogramType
  from nemo.utils import logging
label_desc: Use image node_id 9 for calling the SpeechEncDecSelfSupervisedModel obj's underlying member method code with example usage: obj.decoder_loss_step(spectrograms, spec_masks, encoded, encoded_len, targets, target_lengths) and returns: loss_value,  loss_val_dict