code: def PruneToFinalTarget(self, num_extra_ngrams):
      # prunes to a specified num_extra_ngrams.  The 'extra_ngrams' refers to
      # the count of n-grams of order higher than args.no_backoff_ngram_order.
      # We construct a sequence of targets that gradually approaches
      # this value.  Doing it iteratively like this is a good way
      # to deal with the fact that sometimes we can't prune a certain
      # n-gram before certain other n-grams are pruned (because
      # they lead to a state that must be kept, or an n-gram exists
      # that backs off to this n-gram).
  
      current_num_extra_ngrams = self.GetNumExtraNgrams()
  
      if num_extra_ngrams >= current_num_extra_ngrams:
          print(
              "make_phone_lm.py: not pruning since target num-extra-ngrams={0} is >= "
              "current num-extra-ngrams={1}".format(
                  num_extra_ngrams, current_num_extra_ngrams
              ),
              file=sys.stderr,
          )
          return
  
      target_sequence = [num_extra_ngrams]
      # two final iterations where the targets differ by factors of 1.1,
      # preceded by two iterations where the targets differ by factors of 1.2.
      for this_factor in [1.1, 1.2]:
          for n in range(0, 2):
              if (
                  int((target_sequence[-1] + 1) * this_factor)
                  < current_num_extra_ngrams
              ):
                  target_sequence.append(
                      int((target_sequence[-1] + 1) * this_factor)
                  )
      # then change in factors of 1.3
      while True:
          this_factor = 1.3
          if (
              int((target_sequence[-1] + 1) * this_factor)
              < current_num_extra_ngrams
          ):
              target_sequence.append(
                  int((target_sequence[-1] + 1) * this_factor)
              )
          else:
              break
  
      target_sequence = list(
          set(target_sequence)
      )  # only keep unique targets.
      target_sequence.sort(reverse=True)
  
      print(
          "make_phone_lm.py: current num-extra-ngrams={0}, pruning with "
          "following sequence of targets: {1}".format(
              current_num_extra_ngrams, target_sequence
          ),
          file=sys.stderr,
      )
      total_like_change_per_word = 0.0
      for target in target_sequence:
          total_like_change_per_word += self.PruneToIntermediateTarget(
              target
          )
  
      if args.verbose >= 1:
          print(
              "make_phone_lm.py: K-L divergence from pruning (upper bound) is "
              "%.4f" % total_like_change_per_word,
              file=sys.stderr,
          )
  
imports: import argparse
  import math
  import sys
  from collections import defaultdict
label_desc: Use image node_id 17 for calling the NgramCounts obj's underlying member method code with example usage: obj.PruneToFinalTarget(num_extra_ngrams) without return types