code: def define_saver(exclude=None):
    
    variables = []
    exclude = exclude or []
    exclude = [re.compile(regex) for regex in exclude]
    for variable in tf.global_variables():
      if any(regex.match(variable.name) for regex in exclude):
        continue
      variables.append(variable)
    saver = tf.train.Saver(variables, keep_checkpoint_every_n_hours=5)
    return saver
docs: Create a saver for the variables we want to checkpoint.
  
    Args:
      exclude: List of regexes to match variable names to exclude.
  
    Returns:
      Saver object.