class_docstr: Basic attention cell wrapper.
  
  Implementation based on https://arxiv.org/abs/1601.06733.
class_docstr_tok: ["Basic","attention","cell","wrapper",".","Implementation","based","on","https",":","\/\/arxiv.org\/abs\/1601.06733","."]
docstr: Create a cell with attention.
  
  Args:
    cell: an RNNCell, an attention is added to it.
    attn_length: integer, the size of an attention window.
    attn_size: integer, the size of an attention vector. Equal to
        cell.output_size by default.
    attn_vec_size: integer, the number of convolutional features calculated
        on attention state and a size of the hidden layer built from
        base cell state. Equal attn_size to by default.
    input_size: integer, the size of a hidden linear layer,
        built from inputs and attention. Derived from the input tensor
        by default.
    state_is_tuple: If True, accepted and returned states are n-tuples, where
      `n = len(cells)`.  By default (False), the states are all
      concatenated along the column axis.
    reuse: (optional) Python boolean describing whether to reuse variables
      in an existing scope.  If not `True`, and the existing scope already has
      the given variables, an error is raised.
  
  Raises:
    TypeError: if cell is not an RNNCell.
    ValueError: if cell returns a state tuple but the flag
        `state_is_tuple` is `False` or if attn_length is zero or less.
docstr_tok: ["Create","a","cell","with","attention",".","Args",":","cell",":","an","RNNCell",",","an","attention","is","added","to","it",".","attn_length",":","integer",",","the","size","of","an","attention","window",".","attn_size",":","integer",",","the","size","of","an","attention","vector",".","Equal","to","cell.output_size","by","default",".","attn_vec_size",":","integer",",","the","number","of","convolutional","features","calculated","on","attention","state","and","a","size","of","the","hidden","layer","built","from","base","cell","state",".","Equal","attn_size","to","by","default",".","input_size",":","integer",",","the","size","of","a","hidden","linear","layer",",","built","from","inputs","and","attention",".","Derived","from","the","input","tensor","by","default",".","state_is_tuple",":","If","True",",","accepted","and","returned","states","are","n-tuples",",","where","`","n","=","len","(","cells",")","`",".","By","default","(","False",")",",","the","states","are","all","concatenated","along","the","column","axis",".","reuse",":","(","optional",")","Python","boolean","describing","whether","to","reuse","variables","in","an","existing","scope",".","If","not","`","True","`",",","and","the","existing","scope","already","has","the","given","variables",",","an","error","is","raised",".","Raises",":","TypeError",":","if","cell","is","not","an","RNNCell",".","ValueError",":","if","cell","returns","a","state","tuple","but","the","flag","`","state_is_tuple","`","is","`","False","`","or","if","attn_length","is","zero","or","less","."]
code: def __init__(
      self,
      cell,
      attn_length,
      attn_size=None,
      attn_vec_size=None,
      input_size=None,
      state_is_tuple=True,
      reuse=None,
  ):
      """Create a cell with attention.
  
      Args:
        cell: an RNNCell, an attention is added to it.
        attn_length: integer, the size of an attention window.
        attn_size: integer, the size of an attention vector. Equal to
            cell.output_size by default.
        attn_vec_size: integer, the number of convolutional features calculated
            on attention state and a size of the hidden layer built from
            base cell state. Equal attn_size to by default.
        input_size: integer, the size of a hidden linear layer,
            built from inputs and attention. Derived from the input tensor
            by default.
        state_is_tuple: If True, accepted and returned states are n-tuples, where
          `n = len(cells)`.  By default (False), the states are all
          concatenated along the column axis.
        reuse: (optional) Python boolean describing whether to reuse variables
          in an existing scope.  If not `True`, and the existing scope already has
          the given variables, an error is raised.
  
      Raises:
        TypeError: if cell is not an RNNCell.
        ValueError: if cell returns a state tuple but the flag
            `state_is_tuple` is `False` or if attn_length is zero or less.
      """
      super(AttentionCellWrapper, self).__init__(_reuse=reuse)
      assert_like_rnncell("cell", cell)
      if _is_sequence(cell.state_size) and not state_is_tuple:
          raise ValueError(
              "Cell returns tuple of states, but the flag "
              "state_is_tuple is not set. State size is: %s"
              % str(cell.state_size)
          )
      if attn_length <= 0:
          raise ValueError(
              "attn_length should be greater than zero, got %s"
              % str(attn_length)
          )
      if not state_is_tuple:
          tf.logging.warn(
              "%s: Using a concatenated state is slower and will soon be "
              "deprecated.  Use state_is_tuple=True.",
              self,
          )
      if attn_size is None:
          attn_size = cell.output_size
      if attn_vec_size is None:
          attn_vec_size = attn_size
      self._state_is_tuple = state_is_tuple
      self._cell = cell
      self._attn_vec_size = attn_vec_size
      self._input_size = input_size
      self._attn_size = attn_size
      self._attn_length = attn_length
      self._reuse = reuse
      self._linear1 = None
      self._linear2 = None
      self._linear3 = None
  
imports: import tensorflow.compat.v1
  import tf_slim
  from tensorflow.python.ops import gen_nn_ops
label_desc: Use image node_id 1 to create a new AttentionCellWrapper object from inherited base classes: rnn_cell with example: obj = AttentionCellWrapper(cell, attn_length, attn_size, attn_vec_size, input_size, state_is_tuple, reuse)