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"]
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      # Get global rank and total number of GPU workers for IterableDataset partitioning, if applicable
      # Global_rank and local_rank is set by LightningModule in Lightning 1.2.0
      self.world_size = 1
      if trainer is not None:
          self.world_size = trainer.world_size
  
      super().__init__(cfg=cfg, trainer=trainer)
      self.preprocessor = (
          SpeechEncDecSelfSupervisedModel.from_config_dict(
              self._cfg.preprocessor
          )
      )
      self.encoder = SpeechEncDecSelfSupervisedModel.from_config_dict(
          self._cfg.encoder
      )
  
      self.decoder_losses = None
  
      if "loss_list" in self._cfg:
          self.decoder_losses = {}
          self.loss_alphas = {}
          self.start_step = {}
          self.output_from_layer = {}
          self.transpose_encoded = {}
          self.targets_from_loss = {}
          self.decoder_losses_active = {}
          # need to be separate for moduledict
  
          for (
              decoder_loss_name,
              decoder_loss_cfg,
          ) in self._cfg.loss_list.items():
              if not decoder_loss_cfg.get(
                  "is_active", True
              ):  # active by default
                  continue
  
              new_decoder_loss = {
                  "decoder": SpeechEncDecSelfSupervisedModel.from_config_dict(
                      decoder_loss_cfg.decoder
                  ),
                  "loss": SpeechEncDecSelfSupervisedModel.from_config_dict(
                      decoder_loss_cfg.loss
                  ),
              }
              new_decoder_loss = nn.ModuleDict(new_decoder_loss)
              self.decoder_losses[decoder_loss_name] = new_decoder_loss
              self.loss_alphas[
                  decoder_loss_name
              ] = decoder_loss_cfg.get("loss_alpha", 1.0)
              self.output_from_layer[
                  decoder_loss_name
              ] = decoder_loss_cfg.get("output_from_layer", None)
              self.targets_from_loss[
                  decoder_loss_name
              ] = decoder_loss_cfg.get("targets_from_loss", None)
              self.start_step[decoder_loss_name] = decoder_loss_cfg.get(
                  "start_step", 0
              )
              self.transpose_encoded[
                  decoder_loss_name
              ] = decoder_loss_cfg.get("transpose_encoded", False)
              self.decoder_losses_active[decoder_loss_name] = True
  
          self.decoder_losses = nn.ModuleDict(self.decoder_losses)
  
      else:
          self.decoder_ssl = (
              SpeechEncDecSelfSupervisedModel.from_config_dict(
                  self._cfg.decoder
              )
          )
          self.loss = SpeechEncDecSelfSupervisedModel.from_config_dict(
              self._cfg.loss
          )
  
      self.spec_augmentation = (
          SpeechEncDecSelfSupervisedModel.from_config_dict(
              self._cfg.spec_augment
          )
      )
  
      # dropout for features/spectrograms (applied before masking)
      self.dropout_features = (
          torch.nn.Dropout(self._cfg.dropout_features)
          if "dropout_features" in self._cfg
          else None
      )
  
      # dropout for targets (applied before quantization)
      self.dropout_features_q = (
          torch.nn.Dropout(self._cfg.dropout_features_q)
          if "dropout_features_q" in self._cfg
          else None
      )
  
      # Feature penalty for preprocessor encodings (for Wav2Vec training)
      if "feature_penalty" in self._cfg:
          self.feat_pen, self.pen_factor = (
              0.0,
              self._cfg.feature_penalty,
          )
      else:
          self.feat_pen, self.pen_factor = None, None
  
      if "access" in self._cfg:
          set_access_cfg(self._cfg.access)
  
      self.apply_masking = True
  
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 2 to create a new SpeechEncDecSelfSupervisedModel object from inherited base classes: ModelPT, ASRModuleMixin, AccessMixin with example: obj = SpeechEncDecSelfSupervisedModel(cfg, trainer)