code: def convert(batch, device):
      def to_device_batch(batch):
          if device is None:
              return batch
          src_xp = chainer.backend.get_array_module(*batch)
          xp = device.xp
          concat = src_xp.concatenate(batch, axis=0)
          sections = list(
              numpy.cumsum(
                  [len(x) for x in batch[:-1]], dtype=numpy.int32
              )
          )
          concat_dst = device.send(concat)
          batch_dst = xp.split(concat_dst, sections)
          return batch_dst
  
      return {
          "xs": to_device_batch([x for x, _ in batch]),
          "ys": to_device_batch([y for _, y in batch]),
      }
  
imports: import argparse
  import datetime
  import io
  from nltk.translate import bleu_score
  import numpy
  import progressbar
  import six
  import chainer
  import chainer.functions
  import chainer.links
  from chainer import training
  from chainer.training import extensions
  import chainerx
label_desc: Use image node_id 2 for calling a global function with example usage: convert(batch, device) and returns: dict, batch_dst, batch