class_docstr: Defines inference for tasks where both the input and output sequences
  are plain text.
  
  Params:
    delimiter: Character by which tokens are delimited. Defaults to space.
    unk_replace: If true, enable unknown token replacement based on attention
      scores.
    unk_mapping: If `unk_replace` is true, this can be the path to a file
      defining a dictionary to improve UNK token replacement. Refer to the
      documentation for more details.
    dump_attention_dir: Save attention scores and plots to this directory.
    dump_attention_no_plot: If true, only save attention scores, not
      attention plots.
    dump_beams: Write beam search debugging information to this file.
class_docstr_tok: ["Defines","inference","for","tasks","where","both","the","input","and","output","sequences","are","plain","text",".","Params",":","delimiter",":","Character","by","which","tokens","are","delimited",".","Defaults","to","space",".","unk_replace",":","If","true",",","enable","unknown","token","replacement","based","on","attention","scores",".","unk_mapping",":","If","`","unk_replace","`","is","true",",","this","can","be","the","path","to","a","file","defining","a","dictionary","to","improve","UNK","token","replacement",".","Refer","to","the","documentation","for","more","details",".","dump_attention_dir",":","Save","attention","scores","and","plots","to","this","directory",".","dump_attention_no_plot",":","If","true",",","only","save","attention","scores",",","not","attention","plots",".","dump_beams",":","Write","beam","search","debugging","information","to","this","file","."]
code: def after_run(self, _run_context, run_values):
      fetches_batch = run_values.results
      for fetches in unbatch_dict(fetches_batch):
          # Convert to unicode
          fetches["predicted_tokens"] = np.char.decode(
              fetches["predicted_tokens"].astype("S"), "utf-8"
          )
          predicted_tokens = fetches["predicted_tokens"]
  
          # If we're using beam search we take the first beam
          if np.ndim(predicted_tokens) > 1:
              predicted_tokens = predicted_tokens[:, 0]
  
          fetches["features.source_tokens"] = np.char.decode(
              fetches["features.source_tokens"].astype("S"), "utf-8"
          )
          source_tokens = fetches["features.source_tokens"]
          source_len = fetches["features.source_len"]
  
          if self._unk_replace_fn is not None:
              # We slice the attention scores so that we do not
              # accidentially replace UNK with a SEQUENCE_END token
              attention_scores = fetches["attention_scores"]
              attention_scores = attention_scores[:, : source_len - 1]
              predicted_tokens = self._unk_replace_fn(
                  source_tokens=source_tokens,
                  predicted_tokens=predicted_tokens,
                  attention_scores=attention_scores,
              )
  
          sent = (
              self.params["delimiter"]
              .join(predicted_tokens)
              .split("SEQUENCE_END")[0]
          )
  
          # Apply postproc
          if self._postproc_fn:
              sent = self._postproc_fn(sent)
  
          sent = sent.strip()
  
          print(sent)
  
file_path: seq2seq/seq2seq/tasks/decode_text.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import functools
  from pydoc import locate
  import numpy
  import tensorflow
  from tensorflow import gfile
  from seq2seq.tasks.inference_task import InferenceTask, unbatch_dict
label_desc: Use image node_id 4 for calling the DecodeText obj's underlying member method code with example usage: obj.after_run(_run_context, run_values) without return types