class_docstr: Discrete unit Synthesizer related modules for speech-to-speech translation.
  
  This is a module of discrete unit prediction network in discrete-unit described
  in `Direct speech-to-speech translation with discrete units`_,
  which converts the sequence of hidden states into the sequence of
  discrete unit (from SSLs).
  
  .. _`Direct speech-to-speech translation with discrete units`:
     https://arxiv.org/abs/2107.05604
docstr: Calculate forward propagation.
  
  Args:
      enc_outputs (LongTensor): Batch of padded character ids (B, T, idim).
      enc_outputs_lengths (LongTensor): Batch of lengths of each input batch (B,).
      feats (Tensor): Batch of padded target features (B, T_feats, odim).
      feats_lengths (LongTensor): Batch of the lengths of each target (B,).
      spembs (Optional[Tensor]): Batch of speaker embeddings (B, spk_embed_dim).
      sids (Optional[Tensor]): Batch of speaker IDs (B, 1).
      lids (Optional[Tensor]): Batch of language IDs (B, 1).
  
  Returns:
      hs
      hlens
docstr_tok: ["Calculate","forward","propagation",".","Args",":","enc_outputs","(","LongTensor",")",":","Batch","of","padded","character","ids","(","B",",","T",",","idim",")",".","enc_outputs_lengths","(","LongTensor",")",":","Batch","of","lengths","of","each","input","batch","(","B",",",")",".","feats","(","Tensor",")",":","Batch","of","padded","target","features","(","B",",","T_feats",",","odim",")",".","feats_lengths","(","LongTensor",")",":","Batch","of","the","lengths","of","each","target","(","B",",",")",".","spembs","(","Optional","[","Tensor","]",")",":","Batch","of","speaker","embeddings","(","B",",","spk_embed_dim",")",".","sids","(","Optional","[","Tensor","]",")",":","Batch","of","speaker","IDs","(","B",",","1",")",".","lids","(","Optional","[","Tensor","]",")",":","Batch","of","language","IDs","(","B",",","1",")",".","Returns",":","hs","hlens"]
code: def forward(
      self,
      enc_outputs: torch.Tensor,
      enc_outputs_lengths: torch.Tensor,
      feats: torch.Tensor,
      feats_lengths: torch.Tensor,
      spembs: Optional[torch.Tensor] = None,
      sids: Optional[torch.Tensor] = None,
      lids: Optional[torch.Tensor] = None,
      return_hs: bool = False,
      return_all_hs: bool = False,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Calculate forward propagation.
  
      Args:
          enc_outputs (LongTensor): Batch of padded character ids (B, T, idim).
          enc_outputs_lengths (LongTensor): Batch of lengths of each input batch (B,).
          feats (Tensor): Batch of padded target features (B, T_feats, odim).
          feats_lengths (LongTensor): Batch of the lengths of each target (B,).
          spembs (Optional[Tensor]): Batch of speaker embeddings (B, spk_embed_dim).
          sids (Optional[Tensor]): Batch of speaker IDs (B, 1).
          lids (Optional[Tensor]): Batch of language IDs (B, 1).
  
      Returns:
          hs
          hlens
      """
  
      enc_outputs = enc_outputs[:, : enc_outputs_lengths.max()]
      feats = feats[:, : feats_lengths.max()]  # for data-parallel
  
      ys = feats
      olens = feats_lengths
  
      # calculate hidden spaces for discrete unit outputs
      hs, hlens = self._forward(
          hs=enc_outputs,
          hlens=enc_outputs_lengths,
          ys=ys,
          olens=olens,
          spembs=spembs,
          sids=sids,
          lids=lids,
          return_hs=return_hs,
          return_all_hs=return_all_hs,
      )
  
      return hs, hlens
  
imports: import logging
  from typing import Any, Dict, List, Optional, Sequence, Tuple
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.asr.decoder.transformer_decoder import TransformerDecoder
  from espnet2.s2st.synthesizer.abs_synthesizer import AbsSynthesizer
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.pytorch_backend.transformer.mask import subsequent_mask
  from espnet.nets.scorer_interface import BatchScorerInterface
label_desc: Use image node_id 2 for calling the TransformerDiscreteSynthesizer obj's underlying member method code with example usage: obj.forward(enc_outputs, enc_outputs_lengths, feats, feats_lengths, spembs, sids, lids, return_hs, return_all_hs) and returns: hs,  hlens