code: def GetProtectedNgrams(self):
      ans = set()
      for n in range(args.no_backoff_ngram_order + 1, args.ngram_order):
          for hist, counts_for_hist in self.counts[n].items():
              # If we have an n-gram (6, 7, 8) -> 9, the following loop will
              # add the backed-off n-grams (7, 8) -> 9 and (8) -> 9 to
              # 'protected-ngrams'.
              reduced_hist = hist
              for _ in reversed(
                  list(range(args.no_backoff_ngram_order, n))
              ):
                  reduced_hist = reduced_hist[
                      1:
                  ]  # shift an element off
                  # the history.
  
                  for word in counts_for_hist.word_to_count.keys():
                      if word != self.backoff_symbol:
                          ans.add(reduced_hist + (word,))
              # The following statement ensures that if we are in a
              # history-state (6, 7, 8), then n-grams (6, 7, 8) and (6, 7) are
              # protected.  This assures that the FST states are accessible.
              reduced_hist = hist
              for _ in reversed(
                  list(range(args.no_backoff_ngram_order, n))
              ):
                  ans.add(reduced_hist)
                  reduced_hist = reduced_hist[
                      :-1
                  ]  # pop an element off the
                  # history
      return ans
  
imports: import argparse
  import math
  import sys
  from collections import defaultdict
label_desc: Use image node_id 12 for calling the NgramCounts obj's underlying member method code with example usage: obj.GetProtectedNgrams() and returns: ans