def METHOD_NAME(imzml_reader, sample_size):
    sample_sp_inds = np.random.choice(imzml_reader.n_spectra, sample_size, replace=False)
    for sp_idx, mzs, ints in imzml_reader.iter_spectra(sample_sp_inds):
        yield sp_idx, mzs, ints