class_docstr: SLI Rec model
  
  :Citation:
  
      Z. Yu, J. Lian, A. Mahmoody, G. Liu and X. Xie, "Adaptive User Modeling with
      Long and Short-Term Preferences for Personailzed Recommendation", in Proceedings of
      the 28th International Joint Conferences on Artificial Intelligence, IJCAI’19,
      Pages 4213-4219, AAAI Press, 2019.
docstr: Apply attention by fully connected layers.
  
  Args:
      query (object): The embedding of target item which is regarded as a query in attention operations.
      user_embedding (object): The output of RNN layers which is regarded as user modeling.
  
  Returns:
      object: Weighted sum of user modeling.
docstr_tok: ["Apply","attention","by","fully","connected","layers",".","Args",":","query","(","object",")",":","The","embedding","of","target","item","which","is","regarded","as","a","query","in","attention","operations",".","user_embedding","(","object",")",":","The","output","of","RNN","layers","which","is","regarded","as","user","modeling",".","Returns",":","object",":","Weighted","sum","of","user","modeling","."]
code: def _attention_fcn(self, query, user_embedding):
      """Apply attention by fully connected layers.
  
      Args:
          query (object): The embedding of target item which is regarded as a query in attention operations.
          user_embedding (object): The output of RNN layers which is regarded as user modeling.
  
      Returns:
          object: Weighted sum of user modeling.
      """
      hparams = self.hparams
      with tf.compat.v1.variable_scope("attention_fcn"):
          query_size = query.shape[1]
          boolean_mask = tf.equal(self.mask, tf.ones_like(self.mask))
  
          attention_mat = tf.compat.v1.get_variable(
              name="attention_mat",
              shape=[user_embedding.shape.as_list()[-1], query_size],
              initializer=self.initializer,
          )
          att_inputs = tf.tensordot(
              user_embedding, attention_mat, [[2], [0]]
          )
  
          queries = tf.reshape(
              tf.tile(query, [1, att_inputs.shape[1]]),
              tf.shape(input=att_inputs),
          )
          last_hidden_nn_layer = tf.concat(
              [
                  att_inputs,
                  queries,
                  att_inputs - queries,
                  att_inputs * queries,
              ],
              -1,
          )
          att_fnc_output = self._fcn_net(
              last_hidden_nn_layer,
              hparams.att_fcn_layer_sizes,
              scope="att_fcn",
          )
          att_fnc_output = tf.squeeze(att_fnc_output, -1)
          mask_paddings = tf.ones_like(att_fnc_output) * (
              -(2**32) + 1
          )
          att_weights = tf.nn.softmax(
              tf.compat.v1.where(
                  boolean_mask, att_fnc_output, mask_paddings
              ),
              name="att_weights",
          )
          output = user_embedding * tf.expand_dims(att_weights, -1)
          return output
  
file_path: recommenders/recommenders/models/deeprec/models/sequential/sli_rec.py
imports: import tensorflow
  from recommenders.models.deeprec.models.sequential.sequential_base_model import SequentialBaseModel
  from tensorflow.compat.v1.nn import dynamic_rnn
  from recommenders.models.deeprec.models.sequential.rnn_cell_implement import Time4LSTMCell
label_desc: Use image node_id 2 for calling the SLI_RECModel obj's underlying member method code with example usage: obj._attention_fcn(query, user_embedding) and returns: output