class_docstr: This is a helper class that provides housekeeping for LSTM cells.
  
  This may be useful for alternative LSTM and similar type of cells.
  The subclasses must implement `_call_cell` method and `num_units` property.
docstr: Run this LSTM on inputs, starting from the given state.
  
  Args:
    inputs: `3-D` tensor with shape `[time_len, batch_size, input_size]`.
    initial_state: a tuple `(initial_cell_state, initial_output)` with tensors
      of shape `[batch_size, self._num_units]`. If this is not provided, the
      cell is expected to create a zero initial state of type `dtype`.
    dtype: The data type for the initial state and expected output. Required
      if `initial_state` is not provided or RNN state has a heterogeneous
      dtype.
    sequence_length: Specifies the length of each sequence in inputs. An
      `int32` or `int64` vector (tensor) size `[batch_size]`, values in `[0,
      time_len).`
      Defaults to `time_len` for each element.
  
  Returns:
    A pair containing:
  
    - Output: A `3-D` tensor of shape `[time_len, batch_size, output_size]`
      or a list of time_len tensors of shape `[batch_size, output_size]`,
      to match the type of the `inputs`.
    - Final state: a tuple `(cell_state, output)` matching `initial_state`.
  
  Raises:
    ValueError: in case of shape mismatches
docstr_tok: ["Run","this","LSTM","on","inputs",",","starting","from","the","given","state",".","Args",":","inputs",":","`","3-D","`","tensor","with","shape","`","[","time_len",",","batch_size",",","input_size","]","`",".","initial_state",":","a","tuple","`","(","initial_cell_state",",","initial_output",")","`","with","tensors","of","shape","`","[","batch_size",",","self._num_units","]","`",".","If","this","is","not","provided",",","the","cell","is","expected","to","create","a","zero","initial","state","of","type","`","dtype","`",".","dtype",":","The","data","type","for","the","initial","state","and","expected","output",".","Required","if","`","initial_state","`","is","not","provided","or","RNN","state","has","a","heterogeneous","dtype",".","sequence_length",":","Specifies","the","length","of","each","sequence","in","inputs",".","An","`","int32","`","or","`","int64","`","vector","(","tensor",")","size","`","[","batch_size","]","`",",","values","in","`","[","0",",","time_len",")",".","`","Defaults","to","`","time_len","`","for","each","element",".","Returns",":","A","pair","containing",":","-","Output",":","A","`","3-D","`","tensor","of","shape","`","[","time_len",",","batch_size",",","output_size","]","`","or","a","list","of","time_len","tensors","of","shape","`","[","batch_size",",","output_size","]","`",",","to","match","the","type","of","the","`","inputs","`",".","-","Final","state",":","a","tuple","`","(","cell_state",",","output",")","`","matching","`","initial_state","`",".","Raises",":","ValueError",":","in","case","of","shape","mismatches"]
code: def call(
      self, inputs, initial_state=None, dtype=None, sequence_length=None
  ):
      """Run this LSTM on inputs, starting from the given state.
  
      Args:
        inputs: `3-D` tensor with shape `[time_len, batch_size, input_size]`.
        initial_state: a tuple `(initial_cell_state, initial_output)` with tensors
          of shape `[batch_size, self._num_units]`. If this is not provided, the
          cell is expected to create a zero initial state of type `dtype`.
        dtype: The data type for the initial state and expected output. Required
          if `initial_state` is not provided or RNN state has a heterogeneous
          dtype.
        sequence_length: Specifies the length of each sequence in inputs. An
          `int32` or `int64` vector (tensor) size `[batch_size]`, values in `[0,
          time_len).`
          Defaults to `time_len` for each element.
  
      Returns:
        A pair containing:
  
        - Output: A `3-D` tensor of shape `[time_len, batch_size, output_size]`
          or a list of time_len tensors of shape `[batch_size, output_size]`,
          to match the type of the `inputs`.
        - Final state: a tuple `(cell_state, output)` matching `initial_state`.
  
      Raises:
        ValueError: in case of shape mismatches
      """
      is_list = isinstance(inputs, list)
      if is_list:
          inputs = array_ops.stack(inputs)
      inputs_shape = inputs.get_shape().with_rank(3)
      if not inputs_shape[2]:
          raise ValueError(
              "Expecting inputs_shape[2] to be set: %s" % inputs_shape
          )
      batch_size = inputs_shape.dims[1].value
      if batch_size is None:
          batch_size = array_ops.shape(inputs)[1]
      time_len = inputs_shape.dims[0].value
      if time_len is None:
          time_len = array_ops.shape(inputs)[0]
  
      # Provide default values for initial_state and dtype
      if initial_state is None:
          if dtype is None:
              raise ValueError(
                  "Either initial_state or dtype needs to be specified"
              )
          z = array_ops.zeros(
              array_ops.stack([batch_size, self.num_units]), dtype=dtype
          )
          initial_state = z, z
      else:
          if len(initial_state) != 2:
              raise ValueError(
                  "Expecting initial_state to be a tuple with length 2 or None"
              )
          if dtype is None:
              dtype = initial_state[0].dtype
  
      # create the actual cell
      if sequence_length is not None:
          sequence_length = ops.convert_to_tensor(sequence_length)
      (
          initial_cell_state,
          initial_output,
      ) = initial_state  # pylint: disable=unpacking-non-sequence
      cell_states, outputs = self._call_cell(
          inputs,
          initial_cell_state,
          initial_output,
          dtype,
          sequence_length,
      )
  
      if sequence_length is not None:
          # Mask out the part beyond sequence_length
          mask = array_ops.transpose(
              array_ops.sequence_mask(
                  sequence_length, time_len, dtype=dtype
              ),
              [1, 0],
          )
          mask = array_ops.tile(
              array_ops.expand_dims(mask, [-1]), [1, 1, self.num_units]
          )
          outputs *= mask
          # Prepend initial states to cell_states and outputs for indexing to work
          # correctly,since we want to access the last valid state at
          # sequence_length - 1, which can even be -1, corresponding to the
          # initial state.
          mod_cell_states = array_ops.concat(
              [
                  array_ops.expand_dims(initial_cell_state, [0]),
                  cell_states,
              ],
              0,
          )
          mod_outputs = array_ops.concat(
              [array_ops.expand_dims(initial_output, [0]), outputs], 0
          )
          final_cell_state = self._gather_states(
              mod_cell_states, sequence_length, batch_size
          )
          final_output = self._gather_states(
              mod_outputs, sequence_length, batch_size
          )
      else:
          # No sequence_lengths used: final state is the last state
          final_cell_state = cell_states[-1]
          final_output = outputs[-1]
  
      if is_list:
          # Input was a list, so return a list
          outputs = array_ops.unstack(outputs)
  
      final_state = rnn_cell_impl.LSTMStateTuple(
          final_cell_state, final_output
      )
      return outputs, final_state
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import six
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.keras.engine import input_spec
  from tensorflow.python.layers import base
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_rnn_ops
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import rnn_cell_impl
label_desc: Use image node_id 3 for calling the LSTMBlockWrapper obj's underlying member method code with example usage: obj.call(inputs, initial_state, dtype, sequence_length) and returns: outputs,  final_state