code: def get_model_combine_iters(
      num_iters,
      num_epochs,
      num_archives,
      max_models_combine,
      num_jobs_final,
  ):
      """Figures out the list of iterations for which we'll use those models
      in the final model-averaging phase.  (note: it's a weighted average
      where the weights are worked out from a subset of training data.)
      """
  
      approx_iters_per_epoch_final = (
          float(num_archives) / num_jobs_final
      )
      # Note: it used to be that we would combine over an entire epoch,
      # but in practice we very rarely would use any weights from towards
      # the end of that range, so we are changing it to use not
      # approx_iters_per_epoch_final, but instead:
      # approx_iters_per_epoch_final/2 + 1,
      # dividing by 2 to use half an epoch, and adding 1 just to make sure
      # it's not zero.
  
      # First work out how many iterations we want to combine over in the final
      # nnet3-combine-fast invocation.
      # The number we use is:
      # min(max(max_models_combine, approx_iters_per_epoch_final/2+1),
      #     iters/2)
      # But if this value is > max_models_combine, then the models
      # are subsampled to get these many models to combine.
  
      num_iters_combine_initial = min(
          int(approx_iters_per_epoch_final / 2) + 1, int(num_iters / 2)
      )
  
      if num_iters_combine_initial > max_models_combine:
          subsample_model_factor = int(
              float(num_iters_combine_initial) / max_models_combine
          )
          num_iters_combine = num_iters_combine_initial
          models_to_combine = set(
              range(
                  num_iters - num_iters_combine_initial + 1,
                  num_iters + 1,
                  subsample_model_factor,
              )
          )
          models_to_combine.add(num_iters)
      else:
          subsample_model_factor = 1
          num_iters_combine = min(max_models_combine, num_iters // 2)
          models_to_combine = set(
              range(num_iters - num_iters_combine + 1, num_iters + 1)
          )
  
      return models_to_combine
  
imports: from __future__ import division
  import argparse
  import glob
  import logging
  import os
  import math
  import re
  import shutil
  import libs.common
  from libs.nnet3.train.dropout_schedule import *
  import unittest
label_desc: Use image node_id 19 for calling a global function with example usage: get_model_combine_iters(num_iters, num_epochs, num_archives, max_models_combine, num_jobs_final) and returns: models_to_combine