class_docstr: Step-by-step decoder with LM fusion.
class_docstr_tok: ["Step-by-step","decoder","with","LM","fusion","."]
docstr: Decode one step.
  
  Note that the implementation of attention here follows the model in
  https://arxiv.org/pdf/1609.08144.pdf, detailed more in
  https://arxiv.org/pdf/1703.08581.pdf.
  
  Args:
    theta: A NestedMap object containing weights' values of this
      layer and its children layers.
    packed_src: A NestedMap to represent the packed source tensors generated
      by the attention model.
    cur_target_info: TargetInfo namedtuple, which represents the targets
      which represents information about the target at this step. It is up
      to the various sub-classes to determine how to process the current
      target.
    decoder_step_state: DecoderStepState which encapsulates the state of the
      decoder before computing outputs at the current step.
    per_step_src_padding: Optional padding to be applied to the source_encs
      which overrides the default padding in source_paddings. Used, for
      example, by the Neural Transducer (NT) decoder.
    use_deterministic_random: whether to use deterministic random numbers when
      needed. Must be set to True if called from functional recurrent.
  
  Returns:
    A tuple (step_out, new_decoder_state) which represent the outputs of the
    decoder (usually logits), and the new decoder state after processing the
    current step.
docstr_tok: ["Decode","one","step",".","Note","that","the","implementation","of","attention","here","follows","the","model","in","https",":","\/\/arxiv.org\/pdf\/1609.08144.pdf",",","detailed","more","in","https",":","\/\/arxiv.org\/pdf\/1703.08581.pdf",".","Args",":","theta",":","A","NestedMap","object","containing","weights","'","values","of","this","layer","and","its","children","layers",".","packed_src",":","A","NestedMap","to","represent","the","packed","source","tensors","generated","by","the","attention","model",".","cur_target_info",":","TargetInfo","namedtuple",",","which","represents","the","targets","which","represents","information","about","the","target","at","this","step",".","It","is","up","to","the","various","sub-classes","to","determine","how","to","process","the","current","target",".","decoder_step_state",":","DecoderStepState","which","encapsulates","the","state","of","the","decoder","before","computing","outputs","at","the","current","step",".","per_step_src_padding",":","Optional","padding","to","be","applied","to","the","source_encs","which","overrides","the","default","padding","in","source_paddings",".","Used",",","for","example",",","by","the","Neural","Transducer","(","NT",")","decoder",".","use_deterministic_random",":","whether","to","use","deterministic","random","numbers","when","needed",".","Must","be","set","to","True","if","called","from","functional","recurrent",".","Returns",":","A","tuple","(","step_out",",","new_decoder_state",")","which","represent","the","outputs","of","the","decoder","(","usually","logits",")",",","and","the","new","decoder","state","after","processing","the","current","step","."]
code: def SingleDecodeStep(
      self,
      theta,
      packed_src,
      cur_target_info,
      decoder_step_state,
      per_step_src_padding=None,
      use_deterministic_random=False,
  ):
      """Decode one step.
  
      Note that the implementation of attention here follows the model in
      https://arxiv.org/pdf/1609.08144.pdf, detailed more in
      https://arxiv.org/pdf/1703.08581.pdf.
  
      Args:
        theta: A NestedMap object containing weights' values of this
          layer and its children layers.
        packed_src: A NestedMap to represent the packed source tensors generated
          by the attention model.
        cur_target_info: TargetInfo namedtuple, which represents the targets
          which represents information about the target at this step. It is up
          to the various sub-classes to determine how to process the current
          target.
        decoder_step_state: DecoderStepState which encapsulates the state of the
          decoder before computing outputs at the current step.
        per_step_src_padding: Optional padding to be applied to the source_encs
          which overrides the default padding in source_paddings. Used, for
          example, by the Neural Transducer (NT) decoder.
        use_deterministic_random: whether to use deterministic random numbers when
          needed. Must be set to True if called from functional recurrent.
  
      Returns:
        A tuple (step_out, new_decoder_state) which represent the outputs of the
        decoder (usually logits), and the new decoder state after processing the
        current step.
      """
      misc_states = decoder_step_state.misc_states
      new_rnn_states = []
      new_rnn_states_0, _ = self.rnn_cell[0].FProp(
          theta.rnn_cell[0],
          decoder_step_state.rnn_states[0],
          py_utils.NestedMap(
              act=[
                  cur_target_info.emb,
                  decoder_step_state.atten_context,
              ],
              padding=cur_target_info.padding,
          ),
      )
      new_rnn_states.append(new_rnn_states_0)
      rnn_out = self.rnn_cell[0].GetOutput(new_rnn_states_0)
  
      (
          new_atten_context,
          new_atten_probs,
          new_atten_states,
      ) = self._ComputeAttention(
          theta,
          rnn_out,
          packed_src,
          decoder_step_state.atten_states,
          per_step_src_padding=per_step_src_padding,
      )
      # Here the attention context is being updated according to the
      # contextualizer (the default contextualizer is a no-op).
      new_atten_context = self.contextualizer.QueryAttention(
          theta.contextualizer,
          rnn_out,
          misc_states,
          new_atten_context,
          packed_src,
      )
      for i, cell in enumerate(self.rnn_cell[1:], 1):
          new_rnn_states_i, _ = cell.FProp(
              theta.rnn_cell[i],
              decoder_step_state.rnn_states[i],
              py_utils.NestedMap(
                  act=[rnn_out, new_atten_context],
                  padding=cur_target_info.padding,
              ),
          )
          new_rnn_states.append(new_rnn_states_i)
          new_rnn_out = cell.GetOutput(new_rnn_states_i)
          new_rnn_out = self._ApplyDropout(
              theta,
              new_rnn_out,
              deterministic=use_deterministic_random,
              extra_seed=i * 1000,
          )
          if i + 1 >= self.params.residual_start > 0:
              rnn_out += new_rnn_out
          else:
              rnn_out = new_rnn_out
  
      step_out = tf.concat([rnn_out, new_atten_context], 1)
  
      return step_out, py_utils.NestedMap(
          rnn_states=new_rnn_states,
          atten_context=new_atten_context,
          atten_probs=new_atten_probs,
          atten_states=new_atten_states,
          misc_states=misc_states,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import math
  import lingvo.compat
  from lingvo.core import attention
  from lingvo.core import base_decoder
  from lingvo.core import base_layer
  from lingvo.core import cluster_factory
  from lingvo.core import layers
  from lingvo.core import plot
  from lingvo.core import py_utils
  from lingvo.core import recurrent
  from lingvo.core import rnn_cell
  from lingvo.core import summary_utils
  from lingvo.core import symbolic
  from lingvo.tasks.asr import contextualizer_base
  from lingvo.tasks.asr import decoder_utils
  from lingvo.tasks.asr import fusion
  from matplotlib import font_manager
  import six
  from six.moves import range
label_desc: Use image node_id 4 for calling the AsrDecoder obj's underlying member method code with example usage: obj.SingleDecodeStep(theta, packed_src, cur_target_info, decoder_step_state, per_step_src_padding, use_deterministic_random) and returns: step_out,  py_utils