class_docstr: Base class for models
class_docstr_tok: ["Base","class","for","models"]
docstr: Soft alignment attention implement.
  
  Args:
      inputs (object): Sequences ready to apply attention.
      attention_size (int): The dimension of attention operation.
  
  Returns:
      object: Weighted sum after attention.
docstr_tok: ["Soft","alignment","attention","implement",".","Args",":","inputs","(","object",")",":","Sequences","ready","to","apply","attention",".","attention_size","(","int",")",":","The","dimension","of","attention","operation",".","Returns",":","object",":","Weighted","sum","after","attention","."]
code: def _attention(self, inputs, attention_size):
      """Soft alignment attention implement.
  
      Args:
          inputs (object): Sequences ready to apply attention.
          attention_size (int): The dimension of attention operation.
  
      Returns:
          object: Weighted sum after attention.
      """
      hidden_size = inputs.shape[2]
      if not attention_size:
          attention_size = hidden_size
  
      attention_mat = tf.compat.v1.get_variable(
          name="attention_mat",
          shape=[inputs.shape[-1], hidden_size],
          initializer=self.initializer,
      )
      att_inputs = tf.tensordot(inputs, attention_mat, [[2], [0]])
  
      query = tf.compat.v1.get_variable(
          name="query",
          shape=[attention_size],
          dtype=tf.float32,
          initializer=self.initializer,
      )
      att_logits = tf.tensordot(
          att_inputs, query, axes=1, name="att_logits"
      )
      att_weights = tf.nn.softmax(att_logits, name="att_weights")
      output = inputs * tf.expand_dims(att_weights, -1)
      return output
  
imports: from os.path import join
  import abc
  import time
  import os
  import numpy
  import tensorflow
  from recommenders.models.deeprec.deeprec_utils import cal_metric
label_desc: Use image node_id 25 for calling the BaseModel obj's underlying member method code with example usage: obj._attention(inputs, attention_size) and returns: output