code: def extract_feature(
      uasr_train_config: Optional[str],
      uasr_model_file: Optional[str],
      data_path_and_name_and_type: Sequence[Tuple[str, str, str]],
      key_file: Optional[str],
      batch_size: int,
      dtype: str,
      num_workers: int,
      allow_variable_data_keys: bool,
      ngpu: int,
      output_dir: str,
      dset: str,
      log_level: Union[int, str],
  ):
      assert check_argument_types()
  
      logging.basicConfig(
          level=log_level,
          format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
      )
  
      output_dir_path = Path(output_dir)
  
      if ngpu >= 1:
          device = "cuda"
      else:
          device = "cpu"
  
      uasr_model, uasr_train_args = UASRTask.build_model_from_file(
          uasr_train_config, uasr_model_file, device
      )
  
      test_iter = UASRTask.build_streaming_iterator(
          data_path_and_name_and_type=data_path_and_name_and_type,
          key_file=key_file,
          batch_size=batch_size,
          dtype=dtype,
          num_workers=num_workers,
          preprocess_fn=UASRTask.build_preprocess_fn(
              uasr_train_args, False
          ),
          collate_fn=UASRTask.build_collate_fn(uasr_train_args, False),
          allow_variable_data_keys=allow_variable_data_keys,
          inference=True,
      )
  
      npy_scp_writers = {}
      for keys, batch in test_iter:
          batch = to_device(batch, "cuda" if ngpu > 0 else "cpu")
  
          if ngpu <= 1:
              data = uasr_model.collect_feats(**batch)
          else:
              data = data_parallel(
                  ForwardAdaptor(uasr_model, "collect_feats"),
                  (),
                  range(ngpu),
                  module_kwargs=batch,
              )
  
          for key, v in data.items():
              for i, (uttid, seq) in enumerate(
                  zip(keys, v.cpu().detach().numpy())
              ):
                  if f"{key}_lengths" in data:
                      length = data[f"{key}_lengths"][i]
                      seq = seq[:length]
                  else:
                      seq = seq[None]
  
                  if (key, dset) not in npy_scp_writers:
                      p = output_dir_path / dset / "collect_feats"
                      npy_scp_writers[(key, dset)] = NpyScpWriter(
                          p / f"data_{key}", p / f"{key}.scp"
                      )
                  npy_scp_writers[(key, dset)][uttid] = seq
  
file_path: espnet/espnet2/bin/uasr_extract_feature.py
imports: import argparse
  import logging
  import sys
  from pathlib import Path
  from typing import Optional, Sequence, Tuple, Union
  from torch.nn.parallel import data_parallel
  from typeguard import check_argument_types
  from espnet2.fileio.npy_scp import NpyScpWriter
  from espnet2.tasks.uasr import UASRTask
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.torch_utils.forward_adaptor import ForwardAdaptor
  from espnet2.utils.types import str2bool, str2triple_str, str_or_none
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 2 for calling a global function with example usage: extract_feature(uasr_train_config, uasr_model_file, data_path_and_name_and_type, key_file, batch_size, dtype, num_workers, allow_variable_data_keys, ngpu, output_dir, dset, log_level) without return types