code: def transcribe(args, rank, world_size):
      dataset = ManifestDataset(args.manifest)
  
      speech_encoder = SpeechEncoder.by_name(
          dense_model_name=args.dense_model,
          quantizer_model_name=args.quantizer_model,
          vocab_size=args.vocab_size,
          deduplicate=args.deduplicate,
          need_f0=args.f0s,
      ).cuda()
  
      output_files = {
          "units": open(
              worker_shard_path(args.output, "units", rank), "w"
          ),
          "durations": None
          if not args.durations
          else open(
              worker_shard_path(args.output, "durations", rank), "w"
          ),
          "f0s": None
          if not args.f0s
          else open(worker_shard_path(args.output, "f0s", rank), "w"),
      }
  
      # DistributedSampler will pad the dataloader to be divisible
      # by the number of workers, which we do not want so we iterate directly
      for i in range(rank, len(dataset), world_size):
          waveform, name = dataset[i]
          encoded = speech_encoder(waveform)
  
          stream_names = ["units", "durations"]
          if args.f0s:
              stream_names += ["f0s"]
  
          for stream_name in stream_names:
              stream = encoded[stream_name]
              stream = [str(int(x)) for x in stream.tolist()]
              stream = args.separator.join(stream)
  
              stream = (
                  f"{name}\t{stream}" if args.preserve_name else stream
              )
              print(stream, file=output_files[stream_name])
  
      for fout in output_files.values():
          if fout:
              fout.close()
  
file_path: textlesslib/tools/distributed_transcribe/transcribe.py
imports: import torch.distributed
  import torch
  import pathlib
  from data_handler import ManifestDataset
  from distributed import init_distributed_context
  import logging
  from textless.data.speech_encoder import SpeechEncoder
label_desc: Use image node_id 3 for calling a global function with example usage: transcribe(args, rank, world_size) without return types