code: def compute_progress_from_time(
      train_time, num_resolutions, num_blocks, stage_times
  ):
      """Computes the same progress value as compute_progress.
  
      Assumes training proceeds according to a schedule specified by stage_times
      and train_time is the amount of elapsed time so far.
  
      Args:
        train_time:
        num_resolutions:
        num_blocks: Number of network blocks.
        stage_times:
  
      Returns:
        progress: A scalar float `Tensor` of the training progress.
      """
      num_stages = (2 * num_resolutions) - 1
      max_progress = num_blocks - 1
  
      progress = 0.0
      for i in range(1, num_stages, 2):
          this_stage_progress = (train_time - stage_times[i - 1]) / (
              stage_times[i] - stage_times[i - 1]
          )
          this_stage_progress = tf.clip_by_value(
              this_stage_progress, 0.0, 1.0
          )
          progress += this_stage_progress
      progress = tf.minimum(progress, max_progress)
  
      return progress
  
imports: import math
  from magenta.models.gansynth.lib import layers
  import tensorflow.compat.v1
  import tf_slim
label_desc: Use image node_id 4 for calling a global function with example usage: compute_progress_from_time(train_time, num_resolutions, num_blocks, stage_times) and returns: progress