code: def build_model(
      cls, args: argparse.Namespace
  ) -> ESPnetDiarizationModel:
      assert check_argument_types()
  
      # 1. frontend
      if args.input_size is None:
          # Extract features in the model
          frontend_class = frontend_choices.get_class(args.frontend)
          frontend = frontend_class(**args.frontend_conf)
          input_size = frontend.output_size()
      elif args.input_size is not None and args.frontend is not None:
          frontend_class = frontend_choices.get_class(args.frontend)
          frontend = frontend_class(**args.frontend_conf)
          input_size = args.input_size + frontend.output_size()
      else:
          # Give features from data-loader
          args.frontend = None
          args.frontend_conf = {}
          frontend = None
          input_size = args.input_size
  
      # 2. Data augmentation for spectrogram
      if args.specaug is not None:
          specaug_class = specaug_choices.get_class(args.specaug)
          specaug = specaug_class(**args.specaug_conf)
      else:
          specaug = None
  
      # 3. Normalization layer
      if args.normalize is not None:
          normalize_class = normalize_choices.get_class(args.normalize)
          normalize = normalize_class(**args.normalize_conf)
      else:
          normalize = None
  
      # 4. Label Aggregator layer
      label_aggregator_class = label_aggregator_choices.get_class(
          args.label_aggregator
      )
      label_aggregator = label_aggregator_class(
          **args.label_aggregator_conf
      )
  
      # 5. Encoder
      encoder_class = encoder_choices.get_class(args.encoder)
      # Note(jiatong): Diarization may not use subsampling when processing
      encoder = encoder_class(
          input_size=input_size, **args.encoder_conf
      )
  
      # 6a. Decoder
      decoder_class = decoder_choices.get_class(args.decoder)
      decoder = decoder_class(
          num_spk=args.num_spk,
          encoder_output_size=encoder.output_size(),
          **args.decoder_conf,
      )
  
      # 6b. Attractor
      if getattr(args, "attractor", None) is not None:
          attractor_class = attractor_choices.get_class(args.attractor)
          attractor = attractor_class(
              encoder_output_size=encoder.output_size(),
              **args.attractor_conf,
          )
      else:
          attractor = None
  
      # 7. Build model
      model = ESPnetDiarizationModel(
          frontend=frontend,
          specaug=specaug,
          normalize=normalize,
          label_aggregator=label_aggregator,
          encoder=encoder,
          decoder=decoder,
          attractor=attractor,
          **args.model_conf,
      )
  
      # FIXME(kamo): Should be done in model?
      # 8. Initialize
      if args.init is not None:
          initialize(model, args.init)
  
      assert check_return_type(model)
      return model
  
imports: import argparse
  from typing import Callable, Collection, Dict, List, Optional, Tuple
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.encoder.conformer_encoder import ConformerEncoder
  from espnet2.asr.encoder.rnn_encoder import RNNEncoder
  from espnet2.asr.encoder.transformer_encoder import TransformerEncoder
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.frontend.default import DefaultFrontend
  from espnet2.asr.frontend.s3prl import S3prlFrontend
  from espnet2.asr.frontend.windowing import SlidingWindow
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.asr.specaug.specaug import SpecAug
  from espnet2.diar.attractor.abs_attractor import AbsAttractor
  from espnet2.diar.attractor.rnn_attractor import RnnAttractor
  from espnet2.diar.decoder.abs_decoder import AbsDecoder
  from espnet2.diar.decoder.linear_decoder import LinearDecoder
  from espnet2.diar.espnet_model import ESPnetDiarizationModel
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.layers.global_mvn import GlobalMVN
  from espnet2.layers.label_aggregation import LabelAggregate
  from espnet2.layers.utterance_mvn import UtteranceMVN
  from espnet2.tasks.abs_task import AbsTask
  from espnet2.torch_utils.initialize import initialize
  from espnet2.train.class_choices import ClassChoices
  from espnet2.train.collate_fn import CommonCollateFn
  from espnet2.train.preprocessor import CommonPreprocessor
  from espnet2.train.trainer import Trainer
  from espnet2.utils.get_default_kwargs import get_default_kwargs
  from espnet2.utils.nested_dict_action import NestedDictAction
  from espnet2.utils.types import int_or_none, str2bool, str_or_none
label_desc: Use image node_id 6 for calling the DiarizationTask obj's underlying member method code with example usage: obj.build_model(cls, args) and returns: model