code: def train_regressor(orig_wordvecs, w2v_W, w2v_vocab):
      """
      Return regressor to map word2vec to RNN word space
  
      Function modified from:
      https://github.com/ryankiros/skip-thoughts/blob/master/training/tools.py
      """
      # Gather all words from word2vec that appear in wordvecs
      d = defaultdict(lambda: 0)
      for w in w2v_vocab.keys():
          d[w] = 1
      shared = OrderedDict()
      count = 0
  
      for w in list(orig_wordvecs.keys())[:-2]:
          if d[w] > 0:
              shared[w] = count
              count += 1
  
      # Get the vectors for all words in 'shared'
      w2v = np.zeros((len(shared), 300), dtype="float32")
      sg = np.zeros((len(shared), 620), dtype="float32")
      for w in shared.keys():
          w2v[shared[w]] = w2v_W[w2v_vocab[w]]
          sg[shared[w]] = orig_wordvecs[w]
  
      train_set = ArrayIterator(X=w2v, y=sg, make_onehot=False)
  
      layers = [
          Linear(nout=620, init=Gaussian(loc=0.0, scale=0.1)),
          Bias(init=Constant(0.0)),
      ]
      clf = Model(layers=layers)
  
      # regression model is trained using default global batch size
      cost = GeneralizedCost(costfunc=SumSquared())
      opt = GradientDescentMomentum(0.1, 0.9, gradient_clip_value=5.0)
      callbacks = Callbacks(clf)
  
      clf.fit(
          train_set,
          num_epochs=20,
          optimizer=opt,
          cost=cost,
          callbacks=callbacks,
      )
      return clf
  
imports: import os
  import numpy
  from collections import defaultdict, OrderedDict
  from neon.layers import LookupTable, RecurrentSum, RecurrentLast, Linear, Bias, GeneralizedCost
  from neon.initializers import Gaussian, Constant
  from neon.data import ArrayIterator
  from neon.data.text_preprocessing import clean_string
  from neon.optimizers import GradientDescentMomentum
  from neon.transforms import SumSquared
  from neon.callbacks.callbacks import Callbacks
  from neon.models import Model
  from neon.util.persist import load_obj, save_obj
  from neon import logger
label_desc: Use image node_id 7 for calling a global function with example usage: train_regressor(orig_wordvecs, w2v_W, w2v_vocab) and returns: clf