code: def get_predictions(
      model, valid_set, time_steps, beam_search=True, num_beams=5
  ):
      """
      Get model outputs for displaying.
      """
      shape = (valid_set.nbatches, model.be.bsz, time_steps)
      if beam_search:
          ypred = model.get_outputs_beam(valid_set, num_beams=num_beams)
          prediction = ypred.reshape(shape).transpose(1, 0, 2)
      else:
          ypred = model.get_outputs(valid_set)
          prediction = ypred.argmax(2).reshape(shape).transpose(1, 0, 2)
  
      groundtruth = valid_set.X[:, : valid_set.nbatches, ::-1]
      prediction = prediction[:, :, ::-1].flatten()
      groundtruth = groundtruth[:, :, ::-1].flatten()
  
      return prediction, groundtruth
  
file_path: neon/examples/char_rae.py
imports: from builtins import str
  from builtins import range
  from neon.backends import gen_backend
  from neon.data import PTB
  from neon.initializers import Uniform
  from neon.layers import GeneralizedCost, Affine, GRU, Seq2Seq
  from neon.models import Model
  from neon.optimizers import RMSProp
  from neon.transforms import Tanh, Logistic, Softmax, CrossEntropyMulti, Misclassification
  from neon.callbacks.callbacks import Callbacks
  from neon.util.argparser import NeonArgparser, extract_valid_args
  from neon import logger
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: get_predictions(model, valid_set, time_steps, beam_search, num_beams) and returns: prediction,  groundtruth