code: def random_progress_generator(duration, interrupted=False):
      progress = 0
      n_steps = 10
      last_t = time.time()
      beta = n_steps / duration
      while progress < n_steps:
          delta = time.time() - last_t
          last_t = time.time()
          if (
              interrupted
              and random.random() + progress / n_steps
              > math.exp(-beta * delta / (n_steps / 4))
          ):
              return  # we can't specify any return value (converted into StopIteration error message) as Py2.7 doesn't support return value in generators.
          if random.random() > math.exp(-beta * delta):
              progress += 1
          yield progress / n_steps
  
imports: from io import StringIO
  import math
  import random
  import time
  from h2o.utils.progressbar import ProgressBar, ProgressBarWidget, PBWBar, PBWPercentage, PBWString, RenderResult
label_desc: Use image node_id 5 for calling a global function with example usage: random_progress_generator(duration, interrupted) without return types