code: def vectorize(doc, vocab, char_vocab=None):
      words = np.asarray(
          [vocab[w.lower()] if w.lower() in vocab else 1 for w in doc]
      ).reshape(1, -1)
      if char_vocab is not None:
          sentence_chars = []
          for w in doc:
              word_chars = []
              for c in w:
                  if c in char_vocab:
                      _cid = char_vocab[c]
                  else:
                      _cid = 1
                  word_chars.append(_cid)
              sentence_chars.append(word_chars)
          sentence_chars = np.expand_dims(
              pad_sentences(sentence_chars, model.word_length), axis=0
          )
          return [words, sentence_chars]
      else:
          return words
  
file_path: nlp-architect/examples/intent_extraction/interactive.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import pickle
  import numpy
  from nlp_architect.models.intent_extraction import MultiTaskIntentModel, Seq2SeqIntentModel
  from nlp_architect.utils.generic import pad_sentences
  from nlp_architect.utils.io import validate_existing_filepath
  from nlp_architect.utils.text import SpacyInstance
label_desc: Use image node_id 4 for calling a global function with example usage: vectorize(doc, vocab, char_vocab) and returns: list, words