code: def run_batch(device, batchsize=64):
      # predict labels by batch
  
      def predict_batch(words_batch):
          xs = nlp_utils.transform_to_array(
              words_batch, vocab, with_label=False
          )
          xs = nlp_utils.convert_seq(
              xs, device=device, with_label=False
          )
          with chainer.using_config(
              "train", False
          ), chainer.no_backprop_mode():
              probs = model.predict(xs, softmax=True)
          answers = model.xp.argmax(probs, axis=1)
          scores = probs[
              model.xp.arange(answers.size), answers
          ].tolist()
          for words, answer, score in zip(words_batch, answers, scores):
              print(
                  "{}\t{:.4f}\t{}".format(
                      answer, score, " ".join(words)
                  )
              )
  
      batch = []
      print("Enter inputs for Batch Predictions")
      for l in sys.stdin:
          l = l.strip()
          if not l:
              if batch:
                  predict_batch(batch)
                  batch = []
              print("# blank line")
              continue
          text = nlp_utils.normalize_text(l)
          words = nlp_utils.split_text(
              text, char_based=setup["char_based"]
          )
          batch.append(words)
          if len(batch) >= batchsize:
              predict_batch(batch)
              batch = []
      if batch:
          predict_batch(batch)
  
file_path: chainer/examples/text_classification/run_text_classifier.py
imports: import argparse
  import json
  import sys
  import chainer
  import numpy
  import nets
  import nlp_utils
label_desc: Use image node_id 3 for calling a global function with example usage: run_batch(device, batchsize) without return types