code: def ApplyBackoff(self):
      # note: in the normal case where args.no_backoff_ngram_order == 2 we
      # don't do backoff for history-length = 1 (i.e. for bigrams)... this is
      # a kind of special LM where we're not going to back off to unigram,
      # there will be no unigram.
      if args.verbose >= 1:
          initial_num_ngrams = self.GetNumNgrams()
      for n in reversed(
          list(range(args.no_backoff_ngram_order, args.ngram_order))
      ):
          this_order_counts = self.counts[n]
          for hist, counts_for_hist in this_order_counts.items():
              backoff_hist = hist[1:]
              backoff_counts_for_hist = self.counts[n - 1][backoff_hist]
              this_discount_total = 0
              for word in counts_for_hist.Words():
                  counts_for_hist.AddCount(word, -1)
                  # You can interpret the following line as incrementing the
                  # count-of-counts for the next-lower order.  Note, however,
                  # that later when we remove n-grams, we'll also add their
                  # counts to the next-lower-order history state, so the
                  # resulting counts won't strictly speaking be
                  # counts-of-counts.
                  backoff_counts_for_hist.AddCount(word, 1)
                  this_discount_total += 1
              counts_for_hist.AddCount(
                  self.backoff_symbol, this_discount_total
              )
  
      if args.verbose >= 1:
          # Note: because D == 1, we completely back off singletons.
          print(
              "make_phone_lm.py: ApplyBackoff() reduced the num-ngrams from "
              "{0} to {1}".format(
                  initial_num_ngrams, self.GetNumNgrams()
              ),
              file=sys.stderr,
          )
  
imports: import argparse
  import math
  import sys
  from collections import defaultdict
label_desc: Use image node_id 5 for calling the NgramCounts obj's underlying member method code with example usage: obj.ApplyBackoff() without return types