class_docstr: Joint model Enhancement and Speech to Text.
class_docstr_tok: ["Joint","model","Enhancement","and","Speech","to","Text","."]
code: def __init__(
      self,
      enh_model: ESPnetEnhancementModel,
      s2t_model: Union[
          ESPnetASRModel, ESPnetSTModel, ESPnetDiarizationModel
      ],
      calc_enh_loss: bool = True,
      bypass_enh_prob: float = 0,  # 0 means do not bypass enhancement for all data
  ):
      assert check_argument_types()
  
      super().__init__()
      self.enh_model = enh_model
      self.s2t_model = s2t_model  # ASR or ST or DIAR model
  
      self.bypass_enh_prob = bypass_enh_prob
  
      self.calc_enh_loss = calc_enh_loss
      if isinstance(self.s2t_model, ESPnetDiarizationModel):
          self.extract_feats_in_collect_stats = False
      else:
          self.extract_feats_in_collect_stats = (
              self.s2t_model.extract_feats_in_collect_stats
          )
  
      if (
          self.enh_model.num_spk is not None
          and self.enh_model.num_spk > 1
          and isinstance(self.s2t_model, ESPnetASRModel)
      ):
          if self.calc_enh_loss:
              logging.warning(
                  "The permutation issue will be handled by the Enh loss"
              )
          else:
              logging.warning(
                  "The permutation issue will be handled by the CTC loss"
              )
  
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 1 to create a new ESPnetEnhS2TModel object from inherited base classes: AbsESPnetModel with example: obj = ESPnetEnhS2TModel(enh_model, s2t_model, calc_enh_loss, bypass_enh_prob)