class_docstr: NPA model(Neural News Recommendation with Attentive Multi-View Learning)
  
  Chuhan Wu, Fangzhao Wu, Mingxiao An, Jianqiang Huang, Yongfeng Huang and Xing Xie:
  NPA: Neural News Recommendation with Personalized Attention, KDD 2019, ADS track.
  
  Attributes:
      word2vec_embedding (numpy.ndarray): Pretrained word embedding matrix.
      hparam (object): Global hyper-parameters.
docstr: The main function to create NPA's logic. The core of NPA
  is a user encoder and a news encoder.
  
  Returns:
      object: a model used to train.
      object: a model used to evaluate and predict.
code: def _build_npa(self):
      """The main function to create NPA's logic. The core of NPA
      is a user encoder and a news encoder.
  
      Returns:
          object: a model used to train.
          object: a model used to evaluate and predict.
      """
      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
      )
      user_indexes = keras.Input(shape=(1,), dtype="int32")
  
      nuser_index = layers.Reshape((1, 1))(user_indexes)
      repeat_uindex = layers.Concatenate(axis=-2)(
          [nuser_index] * (hparams.npratio + 1)
      )
      pred_title_uindex = layers.Concatenate(axis=-1)(
          [pred_input_title, repeat_uindex]
      )
      pred_title_uindex_one = layers.Concatenate()(
          [pred_title_one_reshape, user_indexes]
      )
  
      embedding_layer = layers.Embedding(
          self.word2vec_embedding.shape[0],
          hparams.word_emb_dim,
          weights=[self.word2vec_embedding],
          trainable=True,
      )
  
      user_embedding_layer = layers.Embedding(
          len(self.train_iterator.uid2index),
          hparams.user_emb_dim,
          trainable=True,
          embeddings_initializer="zeros",
      )
  
      titleencoder = self._build_newsencoder(
          embedding_layer, user_embedding_layer
      )
      userencoder = self._build_userencoder(
          titleencoder, user_embedding_layer
      )
      newsencoder = titleencoder
  
      user_present = userencoder([his_input_title, user_indexes])
  
      news_present = layers.TimeDistributed(newsencoder)(
          pred_title_uindex
      )
      news_present_one = newsencoder(pred_title_uindex_one)
  
      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(
          [user_indexes, his_input_title, pred_input_title], preds
      )
      scorer = keras.Model(
          [user_indexes, his_input_title, pred_input_title_one],
          pred_one,
      )
  
      return model, scorer
  
file_path: recommenders/recommenders/models/newsrec/models/npa.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 PersonalizedAttentivePooling
label_desc: Use image node_id 6 for calling the NPAModel obj's underlying member method code with example usage: obj._build_npa() and returns: model,  scorer