code: def __init__(
      self,
      n_uid,
      n_mid,
      n_cat,
      EMBEDDING_DIM,
      HIDDEN_SIZE,
      ATTENTION_SIZE,
      lr,
      data_type="FP32",
      use_negsampling=False,
  ):
      tf.reset_default_graph()
      if data_type == "FP32":
          self.model_dtype = tf.float32
      elif data_type == "FP16":
          self.model_dtype = tf.float16
      else:
          invalidInputError(
              False, "Invalid model data type: %s" % data_type
          )
  
      with tf.name_scope("Inputs"):
          self.uid_batch_ph = tf.placeholder(
              tf.int32,
              [
                  None,
              ],
              name="uid_batch_ph",
          )
          self.mid_his_batch_ph = tf.placeholder(
              tf.int32, [None, None], name="mid_his_batch_ph"
          )
          self.cat_his_batch_ph = tf.placeholder(
              tf.int32, [None, None], name="cat_his_batch_ph"
          )
          self.mask = tf.placeholder(
              self.model_dtype, [None, None], name="mask"
          )
          self.seq_len_ph = tf.placeholder(
              tf.int32, [None], name="seq_len_ph"
          )
          self.lr = lr
          self.use_negsampling = use_negsampling
          self.mid_batch_ph = tf.placeholder(
              tf.int32,
              [
                  None,
              ],
              name="mid_batch_ph",
          )
          self.cat_batch_ph = tf.placeholder(
              tf.int32,
              [
                  None,
              ],
              name="cat_batch_ph",
          )
          self.target_ph = tf.placeholder(
              tf.float32, [None, None], name="target_ph"
          )
          if use_negsampling:
              self.noclk_mid_batch_ph = tf.placeholder(
                  tf.int32,
                  [None, None, None],
                  name="noclk_mid_batch_ph",
              )
              # generate 3 item IDs from negative sampling.
              self.noclk_cat_batch_ph = tf.placeholder(
                  tf.int32,
                  [None, None, None],
                  name="noclk_cat_batch_ph",
              )
  
      # Embedding layer
      with tf.name_scope("Embedding_layer"):
          self.uid_embeddings_var = tf.get_variable(
              "uid_embedding_var",
              [n_uid, EMBEDDING_DIM],
              dtype=self.model_dtype,
          )
          tf.summary.histogram(
              "uid_embeddings_var", self.uid_embeddings_var
          )
          self.uid_batch_embedded = tf.nn.embedding_lookup(
              self.uid_embeddings_var, self.uid_batch_ph
          )
  
          self.mid_embeddings_var = tf.get_variable(
              "mid_embedding_var",
              [n_mid, EMBEDDING_DIM],
              dtype=self.model_dtype,
          )
  
          tf.summary.histogram(
              "mid_embeddings_var", self.mid_embeddings_var
          )
          self.mid_batch_embedded = tf.nn.embedding_lookup(
              self.mid_embeddings_var, self.mid_batch_ph
          )
          self.mid_his_batch_embedded = tf.nn.embedding_lookup(
              self.mid_embeddings_var, self.mid_his_batch_ph
          )
          if self.use_negsampling:
              self.noclk_mid_his_batch_embedded = (
                  tf.nn.embedding_lookup(
                      self.mid_embeddings_var, self.noclk_mid_batch_ph
                  )
              )
  
          self.cat_embeddings_var = tf.get_variable(
              "cat_embedding_var",
              [n_cat, EMBEDDING_DIM],
              dtype=self.model_dtype,
          )
  
          tf.summary.histogram(
              "cat_embeddings_var", self.cat_embeddings_var
          )
          self.cat_batch_embedded = tf.nn.embedding_lookup(
              self.cat_embeddings_var, self.cat_batch_ph
          )
          self.cat_his_batch_embedded = tf.nn.embedding_lookup(
              self.cat_embeddings_var, self.cat_his_batch_ph
          )
          if self.use_negsampling:
              self.noclk_cat_his_batch_embedded = (
                  tf.nn.embedding_lookup(
                      self.cat_embeddings_var, self.noclk_cat_batch_ph
                  )
              )
  
      self.item_eb = tf.concat(
          [self.mid_batch_embedded, self.cat_batch_embedded], 1
      )
      self.item_his_eb = tf.concat(
          [self.mid_his_batch_embedded, self.cat_his_batch_embedded], 2
      )
      self.item_his_eb_sum = tf.reduce_sum(self.item_his_eb, 1)
      if self.use_negsampling:
          self.noclk_item_his_eb = tf.concat(
              [
                  self.noclk_mid_his_batch_embedded[:, :, 0, :],
                  self.noclk_cat_his_batch_embedded[:, :, 0, :],
              ],
              -1,
          )
          # 0 means only using the first negative item ID. 3 item IDs are inputed in the line 24.
          self.noclk_item_his_eb = tf.reshape(
              self.noclk_item_his_eb,
              [-1, tf.shape(self.noclk_mid_his_batch_embedded)[1], 36],
          )
          # cat embedding 18 concate item embedding 18.
  
          self.noclk_his_eb = tf.concat(
              [
                  self.noclk_mid_his_batch_embedded,
                  self.noclk_cat_his_batch_embedded,
              ],
              -1,
          )
          self.noclk_his_eb_sum_1 = tf.reduce_sum(self.noclk_his_eb, 2)
          self.noclk_his_eb_sum = tf.reduce_sum(
              self.noclk_his_eb_sum_1, 1
          )
  
imports: import tensorflow
  from rnn import dynamic_rnn
  from utils import *
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 1 to create a new Model object from inherited base classes: object with example: obj = Model(n_uid, n_mid, n_cat, EMBEDDING_DIM, HIDDEN_SIZE, ATTENTION_SIZE, lr, data_type, use_negsampling)