def inner_bucket_shuffle(batches, seed, bucket_size=10, thr=0):
            """we assert batches is sorted form long to short.
                shuffle samples in a buctet(e.g. 10 batches).
                batches: a list of numpy array"""
            num_batch = len(batches)
            new_batches = []
            num_buckets = len(batches) // bucket_size
            i = 0
            while i < num_batch:
                if (i < bucket_size * thr or 
                    i >= bucket_size * (num_buckets - thr)
                ):
                    new_batches.append(batches[i])
                    i += 1
                else:
                    group = np.concatenate(batches[i: i+bucket_size])
                    with data_utils.numpy_seed(seed):
                        np.random.shuffle(group)
                    new_batches += np.array_split(group, bucket_size)
                    i += bucket_size
            assert all([len(batch) > 0 for batch in new_batches])
            return new_batches
we assert batches is sorted form long to short.
                shuffle samples in a buctet(e.g. 10 batches).
                batches: a list of numpy array
speechlm/speechlm/data/multimodal_corpus_dataset.py