code: def to_sample(vectors, label, embedding_dim):
      # flatten nested list
      flatten_features = list(itertools.chain(*vectors))
      features = np.array(flatten_features, dtype="float").reshape(
          [sequence_len, embedding_dim]
      )
  
      return Sample.from_ndarray(features, np.array(label))
  
file_path: BigDL/python/dllib/src/bigdl/dllib/models/textclassifier/textclassifier.py
imports: import itertools
  import re
  from optparse import OptionParser
  from bigdl.dllib.feature.dataset import news20
  from bigdl.dllib.nn.layer import *
  from bigdl.dllib.nn.criterion import *
  from bigdl.dllib.optim.optimizer import *
  from bigdl.dllib.utils.common import *
  from bigdl.dllib.nncontext import *
  from bigdl.dllib.utils.utils import detect_conda_env_name
  import os
  import datetime
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 5 for calling a global function with example usage: to_sample(vectors, label, embedding_dim) and returns: Sample