parameters: (self, inputs, state, scope=None)
return_statement: return output, states
docstring: Run one step of GridRNN.
  
      Args:
        inputs: input Tensor, 2D, batch x input_size. Or None
        state: state Tensor, 2D, batch x state_size. Note that state_size = cell_state_size * recurrent_dims
        scope: VariableScope for the created subgraph; defaults to "GridRNNCell".
  
      Returns:
        A tuple containing:
        - A 2D, batch x output_size, Tensor representing the output of the cell
          after reading "inputs" when previous state was "state".
        - A 2D, batch x state_size, Tensor representing the new state of the cell
          after reading "inputs" when previous state was "state".
docstring_summary: Run one step of GridRNN.
docstring_tokens: Run one step of GridRNN .
function: def __call__(self, inputs, state, scope=None):
      """Run one step of GridRNN.
  
      Args:
        inputs: input Tensor, 2D, batch x input_size. Or None
        state: state Tensor, 2D, batch x state_size. Note that state_size = cell_state_size * recurrent_dims
        scope: VariableScope for the created subgraph; defaults to "GridRNNCell".
  
      Returns:
        A tuple containing:
        - A 2D, batch x output_size, Tensor representing the output of the cell
          after reading "inputs" when previous state was "state".
        - A 2D, batch x state_size, Tensor representing the new state of the cell
          after reading "inputs" when previous state was "state".
      """
      state_sz = state.get_shape().as_list()[1]
      if self.state_size != state_sz:
        raise ValueError('Actual state size not same as specified: {} vs {}.'.format(state_sz, self.state_size))
  
      conf = self._config
      dtype = inputs.dtype if inputs is not None else state.dtype
  
      # c_prev is `m`, and m_prev is `h` in the paper. Keep c and m here for consistency with the codebase
      c_prev = [None] * self._config.num_dims
      m_prev = [None] * self._config.num_dims
      cell_output_size = self._cell.state_size - conf.num_units
  
      # for LSTM   : state = memory cell + output, hence cell_output_size > 0
      # for GRU/RNN: state = output (whose size is equal to _num_units), hence cell_output_size = 0
      for recurrent_dim, start_idx in zip(self._config.recurrents, range(0, self.state_size, self._cell.state_size)):
        if cell_output_size > 0:
          c_prev[recurrent_dim] = array_ops.slice(state, [0, start_idx], [-1, conf.num_units])
          m_prev[recurrent_dim] = array_ops.slice(state, [0, start_idx + conf.num_units], [-1, cell_output_size])
        else:
          m_prev[recurrent_dim] = array_ops.slice(state, [0, start_idx], [-1, conf.num_units])
  
      new_output = [None] * conf.num_dims
      new_state = [None] * conf.num_dims
  
      with vs.variable_scope(scope or type(self).__name__):  # GridRNNCell
  
        # project input
        if inputs is not None and sum(inputs.get_shape().as_list()) > 0 and len(conf.inputs) > 0:
          input_splits = array_ops.split(1, len(conf.inputs), inputs)
          input_sz = input_splits[0].get_shape().as_list()[1]
  
          for i, j in enumerate(conf.inputs):
            input_project_m = vs.get_variable('project_m_{}'.format(j), [input_sz, conf.num_units], dtype=dtype)
            m_prev[j] = math_ops.matmul(input_splits[i], input_project_m)
  
            if cell_output_size > 0:
              input_project_c = vs.get_variable('project_c_{}'.format(j), [input_sz, conf.num_units], dtype=dtype)
              c_prev[j] = math_ops.matmul(input_splits[i], input_project_c)
  
  
        _propagate(conf.non_priority, conf, self._cell, c_prev, m_prev, new_output, new_state, True)
        _propagate(conf.priority, conf, self._cell, c_prev, m_prev, new_output, new_state, False)
  
        output_tensors = [new_output[i] for i in self._config.outputs]
        output = array_ops.zeros([0, 0], dtype) if len(output_tensors) == 0 else array_ops.concat(1,
                                                                                                         output_tensors)
  
        state_tensors = [new_state[i] for i in self._config.recurrents]
        states = array_ops.zeros([0, 0], dtype) if len(state_tensors) == 0 else array_ops.concat(1, state_tensors)
  
      return output, states
function_tokens: def __call__ ( self , inputs , state , scope = None ) : state_sz = state . get_shape ( ) . as_list ( ) [ 1 ] if self . state_size != state_sz : raise ValueError ( 'Actual state size not same as specified: {} vs {}.' . format ( state_sz , self . state_size ) ) conf = self . _config dtype = inputs . dtype if inputs is not None else state . dtype # c_prev is `m`, and m_prev is `h` in the paper. Keep c and m here for consistency with the codebase c_prev = [ None ] * self . _config . num_dims m_prev = [ None ] * self . _config . num_dims cell_output_size = self . _cell . state_size - conf . num_units # for LSTM   : state = memory cell + output, hence cell_output_size > 0 # for GRU/RNN: state = output (whose size is equal to _num_units), hence cell_output_size = 0 for recurrent_dim , start_idx in zip ( self . _config . recurrents , range ( 0 , self . state_size , self . _cell . state_size ) ) : if cell_output_size > 0 : c_prev [ recurrent_dim ] = array_ops . slice ( state , [ 0 , start_idx ] , [ - 1 , conf . num_units ] ) m_prev [ recurrent_dim ] = array_ops . slice ( state , [ 0 , start_idx + conf . num_units ] , [ - 1 , cell_output_size ] ) else : m_prev [ recurrent_dim ] = array_ops . slice ( state , [ 0 , start_idx ] , [ - 1 , conf . num_units ] ) new_output = [ None ] * conf . num_dims new_state = [ None ] * conf . num_dims with vs . variable_scope ( scope or type ( self ) . __name__ ) : # GridRNNCell # project input if inputs is not None and sum ( inputs . get_shape ( ) . as_list ( ) ) > 0 and len ( conf . inputs ) > 0 : input_splits = array_ops . split ( 1 , len ( conf . inputs ) , inputs ) input_sz = input_splits [ 0 ] . get_shape ( ) . as_list ( ) [ 1 ] for i , j in enumerate ( conf . inputs ) : input_project_m = vs . get_variable ( 'project_m_{}' . format ( j ) , [ input_sz , conf . num_units ] , dtype = dtype ) m_prev [ j ] = math_ops . matmul ( input_splits [ i ] , input_project_m ) if cell_output_size > 0 : input_project_c = vs . get_variable ( 'project_c_{}' . format ( j ) , [ input_sz , conf . num_units ] , dtype = dtype ) c_prev [ j ] = math_ops . matmul ( input_splits [ i ] , input_project_c ) _propagate ( conf . non_priority , conf , self . _cell , c_prev , m_prev , new_output , new_state , True ) _propagate ( conf . priority , conf , self . _cell , c_prev , m_prev , new_output , new_state , False ) output_tensors = [ new_output [ i ] for i in self . _config . outputs ] output = array_ops . zeros ( [ 0 , 0 ] , dtype ) if len ( output_tensors ) == 0 else array_ops . concat ( 1 , output_tensors ) state_tensors = [ new_state [ i ] for i in self . _config . recurrents ] states = array_ops . zeros ( [ 0 , 0 ] , dtype ) if len ( state_tensors ) == 0 else array_ops . concat ( 1 , state_tensors ) return output , states