parameters: (self,
                   embedding,
                   start_tokens,
                   end_token,
                   initial_state)
return_statement: return (finished, start_inputs, initial_state)
docstring: Initialize the decoder.
  
      Args:
        embedding: A tensor from the embedding layer output, which is the
          `params` argument for `embedding_lookup`.
        start_tokens: `int32` vector shaped `[batch_size]`, the start tokens.
        end_token: `int32` scalar, the token that marks end of decoding.
        initial_state: A (possibly nested tuple of...) tensors and TensorArrays.
      Returns:
        `(finished, start_inputs, initial_state)`.
      Raises:
        ValueError: If `start_tokens` is not a vector or `end_token` is not a
          scalar.
docstring_summary: Initialize the decoder.
docstring_tokens: Initialize the decoder .
function: def initialize(self,
                   embedding,
                   start_tokens,
                   end_token,
                   initial_state):
      """Initialize the decoder.
  
      Args:
        embedding: A tensor from the embedding layer output, which is the
          `params` argument for `embedding_lookup`.
        start_tokens: `int32` vector shaped `[batch_size]`, the start tokens.
        end_token: `int32` scalar, the token that marks end of decoding.
        initial_state: A (possibly nested tuple of...) tensors and TensorArrays.
      Returns:
        `(finished, start_inputs, initial_state)`.
      Raises:
        ValueError: If `start_tokens` is not a vector or `end_token` is not a
          scalar.
      """
      if embedding is not None and self._embedding_fn is not None:
        raise ValueError(
            "embedding and embedding_fn cannot be provided at same time")
      elif embedding is not None:
        self._embedding_fn = (
            lambda ids: embedding_ops.embedding_lookup(embedding, ids))
  
      self._start_tokens = ops.convert_to_tensor(
          start_tokens, dtype=dtypes.int32, name="start_tokens")
      if self._start_tokens.get_shape().ndims != 1:
        raise ValueError("start_tokens must be a vector")
      self._end_token = ops.convert_to_tensor(
          end_token, dtype=dtypes.int32, name="end_token")
      if self._end_token.get_shape().ndims != 0:
        raise ValueError("end_token must be a scalar")
  
      self._batch_size = array_ops.size(start_tokens)
      self._initial_cell_state = nest.map_structure(
          self._maybe_split_batch_beams, initial_state, self._cell.state_size)
      self._start_tokens = array_ops.tile(
          array_ops.expand_dims(self._start_tokens, 1), [1, self._beam_width])
      self._start_inputs = self._embedding_fn(self._start_tokens)
  
      self._finished = array_ops.one_hot(
          array_ops.zeros([self._batch_size], dtype=dtypes.int32),
          depth=self._beam_width,
          on_value=False,
          off_value=True,
          dtype=dtypes.bool)
  
      finished, start_inputs = self._finished, self._start_inputs
  
      dtype = nest.flatten(self._initial_cell_state)[0].dtype
      log_probs = array_ops.one_hot(  # shape(batch_sz, beam_sz)
          array_ops.zeros([self._batch_size], dtype=dtypes.int32),
          depth=self._beam_width,
          on_value=ops.convert_to_tensor(0.0, dtype=dtype),
          off_value=ops.convert_to_tensor(-np.Inf, dtype=dtype),
          dtype=dtype)
      init_attention_probs = get_attention_probs(
          self._initial_cell_state, self._coverage_penalty_weight)
      if init_attention_probs is None:
        init_attention_probs = ()
  
      initial_state = BeamSearchDecoderState(
          cell_state=self._initial_cell_state,
          log_probs=log_probs,
          finished=finished,
          lengths=array_ops.zeros(
              [self._batch_size, self._beam_width], dtype=dtypes.int64),
          accumulated_attention_probs=init_attention_probs)
  
      return (finished, start_inputs, initial_state)
function_tokens: def initialize ( self , embedding , start_tokens , end_token , initial_state ) : if embedding is not None and self . _embedding_fn is not None : raise ValueError ( "embedding and embedding_fn cannot be provided at same time" ) elif embedding is not None : self . _embedding_fn = ( lambda ids : embedding_ops . embedding_lookup ( embedding , ids ) ) self . _start_tokens = ops . convert_to_tensor ( start_tokens , dtype = dtypes . int32 , name = "start_tokens" ) if self . _start_tokens . get_shape ( ) . ndims != 1 : raise ValueError ( "start_tokens must be a vector" ) self . _end_token = ops . convert_to_tensor ( end_token , dtype = dtypes . int32 , name = "end_token" ) if self . _end_token . get_shape ( ) . ndims != 0 : raise ValueError ( "end_token must be a scalar" ) self . _batch_size = array_ops . size ( start_tokens ) self . _initial_cell_state = nest . map_structure ( self . _maybe_split_batch_beams , initial_state , self . _cell . state_size ) self . _start_tokens = array_ops . tile ( array_ops . expand_dims ( self . _start_tokens , 1 ) , [ 1 , self . _beam_width ] ) self . _start_inputs = self . _embedding_fn ( self . _start_tokens ) self . _finished = array_ops . one_hot ( array_ops . zeros ( [ self . _batch_size ] , dtype = dtypes . int32 ) , depth = self . _beam_width , on_value = False , off_value = True , dtype = dtypes . bool ) finished , start_inputs = self . _finished , self . _start_inputs dtype = nest . flatten ( self . _initial_cell_state ) [ 0 ] . dtype log_probs = array_ops . one_hot ( # shape(batch_sz, beam_sz) array_ops . zeros ( [ self . _batch_size ] , dtype = dtypes . int32 ) , depth = self . _beam_width , on_value = ops . convert_to_tensor ( 0.0 , dtype = dtype ) , off_value = ops . convert_to_tensor ( - np . Inf , dtype = dtype ) , dtype = dtype ) init_attention_probs = get_attention_probs ( self . _initial_cell_state , self . _coverage_penalty_weight ) if init_attention_probs is None : init_attention_probs = ( ) initial_state = BeamSearchDecoderState ( cell_state = self . _initial_cell_state , log_probs = log_probs , finished = finished , lengths = array_ops . zeros ( [ self . _batch_size , self . _beam_width ] , dtype = dtypes . int64 ) , accumulated_attention_probs = init_attention_probs ) return ( finished , start_inputs , initial_state )