code: def pad_sentences(
      sentences, sentence_length=None, dtype=np.int32, pad_val=0.0
  ):
      lengths = [len(sent) for sent in sentences]
  
      nsamples = len(sentences)
      if sentence_length is None:
          sentence_length = np.max(lengths)
  
      X = (np.ones((nsamples, sentence_length)) * pad_val).astype(
          dtype=np.int32
      )
      for i, sent in enumerate(sentences):
          trunc = sent[-sentence_length:]
          X[i, -len(trunc) :] = trunc
      return X
  
file_path: neon/neon/data/text_preprocessing.py
imports: from future import standard_library
  from builtins import map
  import numpy
  import re
  from neon.util.compat import pickle
label_desc: Use image node_id 2 for calling a global function with example usage: pad_sentences(sentences, sentence_length, dtype, pad_val) and returns: X