code: def _batch_worker_fn(
      samples, batchify_fn, dataset=None, counter=None
  ):
      """Function for processing data in worker process."""
      # pylint: disable=unused-argument
      # it is required that each worker process has to fork a new MXIndexedRecordIO handle
      # preserving dataset as global variable can save tons of overhead and is safe in new process
      if len(dataset[0]) > 1:
          if isinstance(samples[0], (list, tuple)):
              batch = [
                  batchify_fn([dataset[i] for i in shard])
                  for shard in samples
              ]
          else:
              batch = batchify_fn([dataset[i] for i in samples])
      else:
          if isinstance(samples[0], (list, tuple)):
              batch = [
                  batchify_fn([dataset[i][0] for i in shard])
                  for shard in samples
              ]
          else:
              batch = batchify_fn([dataset[i][0] for i in samples])
      buf = io.BytesIO()
      ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(batch)
      return buf.getvalue(), counter
  
imports: import io
  import os
  import gc
  import glob
  import pickle
  import warnings
  import multiprocessing
  from functools import partial
  import numpy
  from mxnet import context, npx
  from mxnet.gluon.data import ArrayDataset, SimpleDataset
  from mxnet.gluon.data.dataloader import ForkingPickler, _as_in_context, default_mp_batchify_fn, default_batchify_fn
label_desc: Use image node_id 3 for calling a global function with example usage: _batch_worker_fn(samples, batchify_fn, dataset, counter) and returns: buf,  counter