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 user encoder of NPA.
  
  Args:
      titleencoder (object): the news encoder of NPA.
  
  Return:
      object: the user encoder of NPA.
code: def _build_userencoder(self, titleencoder, user_embedding_layer):
      """The main function to create user encoder of NPA.
  
      Args:
          titleencoder (object): the news encoder of NPA.
  
      Return:
          object: the user encoder of NPA.
      """
      hparams = self.hparams
  
      his_input_title = keras.Input(
          shape=(hparams.his_size, hparams.title_size), dtype="int32"
      )
      user_indexes = keras.Input(shape=(1,), dtype="int32")
  
      nuser_id = layers.Reshape((1, 1))(user_indexes)
      repeat_uids = layers.Concatenate(axis=-2)(
          [nuser_id] * hparams.his_size
      )
      his_title_uid = layers.Concatenate(axis=-1)(
          [his_input_title, repeat_uids]
      )
  
      click_title_presents = layers.TimeDistributed(titleencoder)(
          his_title_uid
      )
  
      u_emb = layers.Reshape((hparams.user_emb_dim,))(
          user_embedding_layer(user_indexes)
      )
      user_present = PersonalizedAttentivePooling(
          hparams.his_size,
          hparams.filter_num,
          hparams.attention_hidden_dim,
          seed=self.seed,
      )(
          [
              click_title_presents,
              layers.Dense(hparams.attention_hidden_dim)(u_emb),
          ]
      )
  
      model = keras.Model(
          [his_input_title, user_indexes],
          user_present,
          name="user_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 4 for calling the NPAModel obj's underlying member method code with example usage: obj._build_userencoder(titleencoder, user_embedding_layer) and returns: model