code: def build_model(class_num):
      model = Sequential()
  
      if model_type.lower() == "cnn":
          model.add(TemporalConvolution(embedding_dim, 256, 5)).add(
              ReLU()
          ).add(TemporalMaxPooling(sequence_len - 5 + 1)).add(
              Squeeze(2)
          )
      elif model_type.lower() == "lstm":
          model.add(Recurrent().add(LSTM(embedding_dim, 256, p)))
          model.add(Select(2, -1))
      elif model_type.lower() == "gru":
          model.add(Recurrent().add(GRU(embedding_dim, 256, p)))
          model.add(Select(2, -1))
  
      model.add(Linear(256, 128)).add(Dropout(0.2)).add(ReLU()).add(
          Linear(128, class_num)
      ).add(LogSoftMax())
  
      return model
  
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 6 for calling a global function with example usage: build_model(class_num) and returns: model