class_docstr: A wrapper that adds positional information,
  masks the input and then runs the latent encoder.
  Arguments
  ---------
  in_dim : int
      Last dimension of input tensor.
  embedding_dim : int
      Dimension to project input to and that the latent encoder will use.
  latent_encoder : torch.nn.module
      Initialized latent encoder object.
  positional_encoding : torch.nn.module
      Uninitialized nn.module for adding positional information, will use ``embedding_dim``.
  dropout_encoder_input : float
      Dropout on encoder input.
  
  Example
  -------
  >>> from speechbrain.lobes.models.transformer.Transformer import TransformerEncoder
  >>> encoder = TransformerEncoder(d_model=768, num_layers=4, nhead=4, d_ffn=1024)
  >>> wrapper = EncoderWrapper(1024, 768, encoder)
  >>> inputs = torch.rand(10, 12, 1024)
  >>> outputs = wrapper(inputs)
  >>> outputs["embeddings"].shape
  torch.Size([10, 12, 768])
docstr: Arguments
  ---------
  latents : torch.Tensor, shape (B, T, C)
      Batch of latent representations (AKA frames) output from latent extractor.
  wav_lens : torch.Tensor, shape (B,)
      The actual (unpadded) relative lengths for each sample of the batch (0<wav_lens<1).
  padding_mask : Torch.Tensor, shape (B, T,)
      Can be provided instead of wav_lens.
  mask : torch.Tensor, shape (B, T)
      Boolean mask which decides which latent frames will be masked.
docstr_tok: ["Arguments","--","--","--","--","-","latents",":","torch.Tensor",",","shape","(","B",",","T",",","C",")","Batch","of","latent","representations","(","AKA","frames",")","output","from","latent","extractor",".","wav_lens",":","torch.Tensor",",","shape","(","B",",",")","The","actual","(","unpadded",")","relative","lengths","for","each","sample","of","the","batch","(","0","<","wav_lens","<","1",")",".","padding_mask",":","Torch.Tensor",",","shape","(","B",",","T",",",")","Can","be","provided","instead","of","wav_lens",".","mask",":","torch.Tensor",",","shape","(","B",",","T",")","Boolean","mask","which","decides","which","latent","frames","will","be","masked","."]
code: def forward(
      self,
      latents,
      wav_lens=None,
      padding_mask=None,
      mask=None,
  ):
      """
      Arguments
      ---------
      latents : torch.Tensor, shape (B, T, C)
          Batch of latent representations (AKA frames) output from latent extractor.
      wav_lens : torch.Tensor, shape (B,)
          The actual (unpadded) relative lengths for each sample of the batch (0<wav_lens<1).
      padding_mask : Torch.Tensor, shape (B, T,)
          Can be provided instead of wav_lens.
      mask : torch.Tensor, shape (B, T)
          Boolean mask which decides which latent frames will be masked.
      """
      results = {}
      T = latents.size(1)
      latents = self.input_projector(latents)
      latents = self.dropout_encoder_input(latents)
  
      if mask is not None:
          latents[mask] = self.mask_emb.to(latents.dtype)
          num_masked = mask.sum()
          results["num_masked"] = num_masked
          results["ratio_masked"] = num_masked / mask.numel()
  
      if wav_lens is not None:
          wav_lens = torch.round(wav_lens * T)
          padding_mask = ~length_to_mask(wav_lens, dtype=bool)
  
      latents = latents + self.positional_encoding(latents)
      feats, _ = self.latent_encoder(
          latents, src_key_padding_mask=padding_mask
      )
  
      results["embeddings"] = feats
      return results
  
imports: import logging
  import torch
  import torch.nn.functional
  import torch.nn
  import random
  import numpy
  from speechbrain.lobes.models.transformer.Transformer import PositionalEncoding
  from speechbrain.utils.data_utils import batch_pad_right
  from speechbrain.dataio.dataio import length_to_mask
  from speechbrain.lobes.models.convolution import ConvolutionFrontEnd
  from speechbrain.nnet.CNN import Conv1d
  from speechbrain.nnet.normalization import LayerNorm
  from speechbrain.nnet.quantisers import GumbelVectorQuantizer
label_desc: Use image node_id 2 for calling the EncoderWrapper obj's underlying member method code with example usage: obj.forward(latents, wav_lens, padding_mask, mask) and returns: results