code: def prepare_bucket_sampler(
      dataset, batch_size, shuffle=False, num_buckets=1
  ):
      lengths = dataset.transform(lambda x: len(x))
      sampler = FixedBucketSampler(
          lengths,
          batch_size=batch_size,
          num_buckets=num_buckets,
          ratio=0,
          shuffle=shuffle,
      )
      return sampler
  
file_path: gluon-nlp/tests/test_data_loading.py
imports: import os
  import sys
  import tempfile
  import pytest
  import mxnet
  import numpy
  from numpy.testing import assert_almost_equal
  from gluonnlp.data.loading import NumpyDataset, DatasetLoader
  from gluonnlp.data.sampler import SplitSampler, FixedBucketSampler
label_desc: Use image node_id 2 for calling a global function with example usage: prepare_bucket_sampler(dataset, batch_size, shuffle, num_buckets) and returns: sampler