class_docstr: NRMS model(Neural News Recommendation with Multi-Head Self-Attention)
  
  Chuhan Wu, Fangzhao Wu, Suyu Ge, Tao Qi, Yongfeng Huang,and Xing Xie, "Neural News
  Recommendation with Multi-Head Self-Attention" in Proceedings of the 2019 Conference
  on Empirical Methods in Natural Language Processing and the 9th International Joint Conference
  on Natural Language Processing (EMNLP-IJCNLP)
  
  Attributes:
      word2vec_embedding (numpy.ndarray): Pretrained word embedding matrix.
      hparam (object): Global hyper-parameters.
docstr: The main function to create NRMS's logic. The core of NRMS
  is a user encoder and a news encoder.
  
  Returns:
      object: a model used to train.
      object: a model used to evaluate and inference.
docstr_tok: ["The","main","function","to","create","NRMS","'s","logic",".","The","core","of","NRMS","is","a","user","encoder","and","a","news","encoder",".","Returns",":","object",":","a","model","used","to","train",".","object",":","a","model","used","to","evaluate","and","inference","."]
code: def _build_nrms(self):
      """The main function to create NRMS's logic. The core of NRMS
      is a user encoder and a news encoder.
  
      Returns:
          object: a model used to train.
          object: a model used to evaluate and inference.
      """
      hparams = self.hparams
  
      his_input_title = keras.Input(
          shape=(hparams.his_size, hparams.title_size), dtype="int32"
      )
      pred_input_title = keras.Input(
          shape=(hparams.npratio + 1, hparams.title_size), dtype="int32"
      )
      pred_input_title_one = keras.Input(
          shape=(
              1,
              hparams.title_size,
          ),
          dtype="int32",
      )
      pred_title_one_reshape = layers.Reshape((hparams.title_size,))(
          pred_input_title_one
      )
  
      embedding_layer = layers.Embedding(
          self.word2vec_embedding.shape[0],
          hparams.word_emb_dim,
          weights=[self.word2vec_embedding],
          trainable=True,
      )
  
      titleencoder = self._build_newsencoder(embedding_layer)
      self.userencoder = self._build_userencoder(titleencoder)
      self.newsencoder = titleencoder
  
      user_present = self.userencoder(his_input_title)
      news_present = layers.TimeDistributed(self.newsencoder)(
          pred_input_title
      )
      news_present_one = self.newsencoder(pred_title_one_reshape)
  
      preds = layers.Dot(axes=-1)([news_present, user_present])
      preds = layers.Activation(activation="softmax")(preds)
  
      pred_one = layers.Dot(axes=-1)([news_present_one, user_present])
      pred_one = layers.Activation(activation="sigmoid")(pred_one)
  
      model = keras.Model([his_input_title, pred_input_title], preds)
      scorer = keras.Model(
          [his_input_title, pred_input_title_one], pred_one
      )
  
      return model, scorer
  
file_path: recommenders/recommenders/models/newsrec/models/nrms.py
imports: import tensorflow.keras
  from tensorflow.keras import layers
  from recommenders.models.newsrec.models.base_model import BaseModel
  from recommenders.models.newsrec.models.layers import AttLayer2, SelfAttention
label_desc: Use image node_id 8 for calling the NRMSModel obj's underlying member method code with example usage: obj._build_nrms() and returns: model,  scorer