class_docstr: DiarizeSpeech class
  
  Examples:
      >>> import soundfile
      >>> diarization = DiarizeSpeech("diar_config.yaml", "diar.pth")
      >>> audio, rate = soundfile.read("speech.wav")
      >>> diarization(audio)
      [(spk_id, start, end), (spk_id2, start2, end2)]
class_docstr_tok: ["DiarizeSpeech","class","Examples",":",">",">",">","import","soundfile",">",">",">","diarization","=","DiarizeSpeech","(","``","diar_config.yaml","''",",","``","diar.pth","''",")",">",">",">","audio",",","rate","=","soundfile.read","(","``","speech.wav","''",")",">",">",">","diarization","(","audio",")","[","(","spk_id",",","start",",","end",")",",","(","spk_id2",",","start2",",","end2",")","]"]
code: def encode(self, speech, lengths):
      if self.enh_s2t_task:
          (
              encoder_out,
              encoder_out_lens,
              _,
          ) = self.diar_model.encode_diar(speech, lengths, self.num_spk)
      else:
          bottleneck_feats = bottleneck_feats_lengths = None
          encoder_out, encoder_out_lens = self.diar_model.encode(
              speech,
              lengths,
              bottleneck_feats,
              bottleneck_feats_lengths,
          )
      return encoder_out, encoder_out_lens
  
imports: import argparse
  import logging
  import sys
  from itertools import permutations
  from pathlib import Path
  from typing import Any, List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
  from tqdm import trange
  from typeguard import check_argument_types
  from espnet2.enh.loss.criterions.tf_domain import FrequencyDomainMSE
  from espnet2.enh.loss.criterions.time_domain import SISNRLoss
  from espnet2.enh.loss.wrappers.pit_solver import PITSolver
  from espnet2.fileio.npy_scp import NpyScpWriter
  from espnet2.fileio.sound_scp import SoundScpWriter
  from espnet2.tasks.diar import DiarizationTask
  from espnet2.tasks.enh_s2t import EnhS2TTask
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
  from espnet2.utils import config_argparse
  from espnet2.utils.types import humanfriendly_parse_size_or_none, int_or_none, str2bool, str2triple_str, str_or_none
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 6 for calling the DiarizeSpeech obj's underlying member method code with example usage: obj.encode(speech, lengths) and returns: encoder_out,  encoder_out_lens