def _worker_fn(samples, batchify_fn, dataset=None):
<EOL>global _worker_dataset<EOL>if isinstance(samples[<NUM_LIT:0>], (list, tuple)):<EOL><INDENT>batch = [batchify_fn([_worker_dataset[i] for i in shard]) for shard in samples]<EOL><DEDENT>else:<EOL><INDENT>batch = batchify_fn([_worker_dataset[i] for i in samples])<EOL><DEDENT>buf = io.BytesIO()<EOL>ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(batch)<EOL>return buf.getvalue()<EOL>
Function for processing data in worker process.