class_docstr: Joint model Enhancement and Speech to Text.
class_docstr_tok: ["Joint","model","Enhancement","and","Speech","to","Text","."]
code: def collect_feats(
      self,
      speech: torch.Tensor,
      speech_lengths: torch.Tensor,
      **kwargs,
  ) -> Dict[str, torch.Tensor]:
      if "text" in kwargs:
          text = kwargs["text"]
          text_lengths = kwargs.get("text_lengths", None)
      else:
          text = kwargs["text_spk1"]
          text_lengths = kwargs.get("text_spk1_lengths", None)
  
      if self.extract_feats_in_collect_stats:
          ret = self.s2t_model.collect_feats(
              speech,
              speech_lengths,
              text,
              text_lengths,
              **kwargs,
          )
          feats, feats_lengths = ret["feats"], ret["feats_lengths"]
      else:
          # Generate dummy stats if extract_feats_in_collect_stats is False
          logging.warning(
              "Generating dummy stats for feats and feats_lengths, "
              "because encoder_conf.extract_feats_in_collect_stats is "
              f"{self.extract_feats_in_collect_stats}"
          )
          feats, feats_lengths = speech, speech_lengths
      return {"feats": feats, "feats_lengths": feats_lengths}
  
imports: import logging
  import random
  from contextlib import contextmanager
  from typing import Dict, List, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
  from packaging.version import parse
  from scipy.optimize import linear_sum_assignment
  from typeguard import check_argument_types
  from espnet2.asr.espnet_model import ESPnetASRModel
  from espnet2.diar.espnet_model import ESPnetDiarizationModel
  from espnet2.enh.espnet_model import ESPnetEnhancementModel
  from espnet2.st.espnet_model import ESPnetSTModel
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
label_desc: Use image node_id 3 for calling the ESPnetEnhS2TModel obj's underlying member method code with example usage: obj.collect_feats(speech, speech_lengths) and returns: dict