code: def setup_model(device, model_setup):
      sys.stderr.write(json.dumps(args.__dict__, indent=2) + "\n")
      setup = json.load(open(model_setup))
      sys.stderr.write(json.dumps(setup, indent=2) + "\n")
  
      vocab = json.load(open(setup["vocab_path"]))
      n_class = setup["n_class"]
  
      # Setup a model
      if setup["model"] == "rnn":
          Encoder = nets.RNNEncoder
      elif setup["model"] == "cnn":
          Encoder = nets.CNNEncoder
      elif setup["model"] == "bow":
          Encoder = nets.BOWMLPEncoder
      encoder = Encoder(
          n_layers=setup["layer"],
          n_vocab=len(vocab),
          n_units=setup["unit"],
          dropout=setup["dropout"],
      )
      model = nets.TextClassifier(encoder, n_class)
      chainer.serializers.load_npz(setup["model_path"], model)
      model.to_device(device)  # Copy the model to the device
  
      return model, vocab, setup
  
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 1 for calling a global function with example usage: setup_model(device, model_setup) and returns: model,  vocab,  setup