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 __init__(
      self,
      train_config: Union[Path, str] = None,
      model_file: Union[Path, str] = None,
      segment_size: Optional[float] = None,
      hop_size: Optional[float] = None,
      normalize_segment_scale: bool = False,
      show_progressbar: bool = False,
      normalize_output_wav: bool = False,
      num_spk: Optional[int] = None,
      device: str = "cpu",
      dtype: str = "float32",
      enh_s2t_task: bool = False,
      multiply_diar_result: bool = False,
  ):
      assert check_argument_types()
  
      task = DiarizationTask if not enh_s2t_task else EnhS2TTask
  
      # 1. Build Diar model
      diar_model, diar_train_args = task.build_model_from_file(
          train_config, model_file, device
      )
      if enh_s2t_task:
          diar_model.inherite_attributes(
              inherite_s2t_attrs=[
                  "decoder",
                  "attractor",
              ],
              inherite_enh_attrs=[
                  "mask_module",
              ],
          )
  
      diar_model.to(dtype=getattr(torch, dtype)).eval()
  
      self.device = device
      self.dtype = dtype
      self.diar_train_args = diar_train_args
      self.diar_model = diar_model
  
      # only used when processing long speech, i.e.
      # segment_size is not None and hop_size is not None
      self.segment_size = segment_size
      self.hop_size = hop_size
      self.normalize_segment_scale = normalize_segment_scale
      self.normalize_output_wav = normalize_output_wav
      self.show_progressbar = show_progressbar
      # not specifying "num_spk" in inference config file
      # will enable speaker number prediction during inference
      self.num_spk = num_spk
  
      # multiply_diar_result corresponds to the "Post-processing"
      # in https://arxiv.org/pdf/2203.17068.pdf
      self.multiply_diar_result = multiply_diar_result
      self.enh_s2t_task = enh_s2t_task
  
      self.segmenting_diar = (
          segment_size is not None and not enh_s2t_task
      )
      self.segmenting_enh_diar = (
          segment_size is not None
          and hop_size is not None
          and enh_s2t_task
      )
      if self.segmenting_diar:
          logging.info("Perform segment-wise speaker diarization")
          logging.info("Segment length = {} sec".format(segment_size))
      elif self.segmenting_enh_diar:
          logging.info(
              "Perform segment-wise speech separation and diarization"
          )
          logging.info(
              "Segment length = {} sec, hop length = {} sec".format(
                  segment_size, hop_size
              )
          )
      else:
          logging.info(
              "Perform direct speaker diarization on the input"
          )
  
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 1 to create a new DiarizeSpeech object  with example: obj = DiarizeSpeech(train_config, model_file, segment_size, hop_size, normalize_segment_scale, show_progressbar, normalize_output_wav, num_spk, device, dtype, enh_s2t_task, multiply_diar_result)