code: def PrintAsFst(self, word_disambig_symbol):
      # n is the history-length (== order + 1).  We iterate over the
      # history-length in the order 1, 0, 2, 3, and then iterate over the
      # histories of each order in sorted order.  Putting order 1 first
      # and sorting on the histories
      # ensures that the bigram state with <s> as the left context comes first.
      # (note: self.bos_symbol is the most negative symbol)
  
      # History will map from history (as a tuple) to integer FST-state.
      hist_to_state = self.GetHistToStateMap()
  
      for n in [1, 0] + list(range(2, args.ngram_order)):
          this_order_counts = self.counts[n]
          # For order 1, make sure the keys are sorted.
          keys = (
              this_order_counts.keys()
              if n != 1
              else sorted(this_order_counts.keys())
          )
          for hist in keys:
              word_to_count = this_order_counts[hist].word_to_count
              this_fst_state = hist_to_state[hist]
  
              for word in word_to_count.keys():
                  # work out this_cost.  Costs in OpenFst are negative logs.
                  this_cost = -math.log(self.GetProb(hist, word))
  
                  if word > 0:  # a real word.
                      next_hist = hist + (word,)  # appending tuples
                      while not next_hist in hist_to_state:
                          next_hist = next_hist[1:]
                      next_fst_state = hist_to_state[next_hist]
                      print(
                          this_fst_state,
                          next_fst_state,
                          word,
                          word,
                          this_cost,
                      )
                  elif word == self.eos_symbol:
                      # print final-prob for this state.
                      print(this_fst_state, this_cost)
                  else:
                      assert word == self.backoff_symbol
                      backoff_fst_state = hist_to_state[
                          hist[1 : len(hist)]
                      ]
                      print(
                          this_fst_state,
                          backoff_fst_state,
                          word_disambig_symbol,
                          0,
                          this_cost,
                      )
  
imports: import argparse
  import math
  import sys
  from collections import defaultdict
label_desc: Use image node_id 11 for calling the NgramCounts obj's underlying member method code with example usage: obj.PrintAsFst(word_disambig_symbol) without return types