code: def dump_label(
      rspecifier,
      in_filetype,
      wspecifier,
      out_filetype,
      km_path,
      use_gpu,
      online_feature_extract,
      **kwargs,
  ):
      if online_feature_extract:
          assert "feature_conf" in kwargs
          # need to wrap arguments with double-quotes for json string
          feature_conf = format_feature_conf_str(kwargs["feature_conf"])
      else:
          feature_conf = None
  
      apply_kmeans = ApplyKmeans(km_path, use_gpu=use_gpu)
  
      if not online_feature_extract:
          # dumped ssl feature in kaldi ark format
          with file_writer_helper(
              wspecifier,
              filetype=out_filetype,
          ) as writer:
              for utt, feat in file_reader_helper(
                  rspecifier, in_filetype
              ):
                  lab = apply_kmeans(feat)
                  writer[utt] = lab
      else:
          assert feature_conf["type"] in feature_reader_choice
          reader_class = feature_reader_choice[feature_conf["type"]]
          reader_conf = feature_conf.get("conf", dict())
  
          if reader_conf.get("multilayer_feature", None):
              reader_conf["multilayer_feature"] = str2bool(
                  reader_conf["multilayer_feature"]
              )
          if reader_conf.get("layer", None):
              reader_conf["layer"] = int(reader_conf["layer"])
  
          reader = reader_class(**reader_conf)
          iterator = build_data_iterator(
              rspecifier,
              in_filetype,
              utt2num_samples=args.utt2num_samples,
              batch_bins=kwargs.get("batch_bins", 1),
          )
          with file_writer_helper(
              wspecifier,
              filetype=out_filetype,
          ) as writer:
              for utt_ids, data in iterator:
                  feats, feats_lens = reader.get_feats(
                      data["speech"], data["speech_lengths"]
                  )
  
                  for idx, utt in enumerate(utt_ids):
                      lab = apply_kmeans(
                          feats[idx][: feats_lens[idx]].numpy()
                      )
                      writer[utt] = lab
  
      logger.info("finished successfully")
  
file_path: espnet/egs2/kiritan/svs1/pyscripts/feats/dump_km_label.py
imports: import argparse
  import logging
  import os
  import sys
  import joblib
  import numpy
  import torch
  from ssl_feature_utils import ESPnetHubertFeatureReader, HubertFeatureReader, MfccFeatureReader, S3PRLFeatureReader, build_data_iterator, format_feature_conf_str
  from espnet2.utils.types import str2bool
  from espnet.utils.cli_readers import file_reader_helper
  from espnet.utils.cli_writers import file_writer_helper
label_desc: Use image node_id 2 for calling a global function with example usage: dump_label(rspecifier, in_filetype, wspecifier, out_filetype, km_path, use_gpu, online_feature_extract) without return types