code: def get_feat_iterator(feat_dir, split, nshard, rank):
      feat_path = f"{feat_dir}/{split}_{rank}_{nshard}.npy"
      leng_path = f"{feat_dir}/{split}_{rank}_{nshard}.len"
      with open(leng_path, "r") as f:
          lengs = [int(line.rstrip()) for line in f]
          offsets = [0] + np.cumsum(lengs[:-1]).tolist()
  
      def iterate():
          feat = np.load(feat_path, mmap_mode="r")
          assert feat.shape[0] == (offsets[-1] + lengs[-1])
          for offset, leng in zip(offsets, lengs):
              yield feat[offset : offset + leng]
  
      return iterate, len(lengs)
  
file_path: fairseq/examples/hubert/simple_kmeans/dump_km_label.py
imports: import logging
  import os
  import sys
  import numpy
  import joblib
  import torch
  import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: get_feat_iterator(feat_dir, split, nshard, rank) and returns: iterate,  len