code: def convert_seq(batch, device=None, with_label=True):
      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 = numpy.cumsum(
              [len(x) for x in batch[:-1]], dtype=numpy.int32
          )
          concat_dev = chainer.dataset.to_device(device, concat)
          batch_dev = xp.split(concat_dev, sections)
          return batch_dev
  
      if with_label:
          return {
              "xs": to_device_batch([x for x, _ in batch]),
              "ys": to_device_batch([y for _, y in batch]),
          }
      else:
          return to_device_batch([x for x in batch])
  
file_path: chainer/examples/text_classification/nlp_utils.py
imports: import collections
  import io
  import numpy
  import chainer
label_desc: Use image node_id 7 for calling a global function with example usage: convert_seq(batch, device, with_label) and returns: batch_dev, dict, to_device_batch, batch