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 news encoder of NPA.
  
  Args:
      embedding_layer (object): a word embedding layer.
  
  Return:
      object: the news encoder of NPA.
code: def _build_newsencoder(self, embedding_layer, user_embedding_layer):
      """The main function to create news encoder of NPA.
  
      Args:
          embedding_layer (object): a word embedding layer.
  
      Return:
          object: the news encoder of NPA.
      """
      hparams = self.hparams
      sequence_title_uindex = keras.Input(
          shape=(hparams.title_size + 1,), dtype="int32"
      )
  
      sequences_input_title = layers.Lambda(
          lambda x: x[:, : hparams.title_size]
      )(sequence_title_uindex)
      user_index = layers.Lambda(lambda x: x[:, hparams.title_size :])(
          sequence_title_uindex
      )
  
      u_emb = layers.Reshape((hparams.user_emb_dim,))(
          user_embedding_layer(user_index)
      )
      embedded_sequences_title = embedding_layer(sequences_input_title)
  
      y = layers.Dropout(hparams.dropout)(embedded_sequences_title)
      y = layers.Conv1D(
          hparams.filter_num,
          hparams.window_size,
          activation=hparams.cnn_activation,
          padding="same",
          bias_initializer=keras.initializers.Zeros(),
          kernel_initializer=keras.initializers.glorot_uniform(
              seed=self.seed
          ),
      )(y)
      y = layers.Dropout(hparams.dropout)(y)
  
      pred_title = PersonalizedAttentivePooling(
          hparams.title_size,
          hparams.filter_num,
          hparams.attention_hidden_dim,
          seed=self.seed,
      )([y, layers.Dense(hparams.attention_hidden_dim)(u_emb)])
  
      # pred_title = Reshape((1, feature_size))(pred_title)
      model = keras.Model(
          sequence_title_uindex, pred_title, name="news_encoder"
      )
      return model
  
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 5 for calling the NPAModel obj's underlying member method code with example usage: obj._build_newsencoder(embedding_layer, user_embedding_layer) and returns: model