def write_checkpoint(current_key, ctr, cluster_mapping, ids, bestscores, order, out_fp):
 checkpoint_dir = (out_fp + '/checkpoints/')
 if (not exists(checkpoint_dir)):
  create_dir(checkpoint_dir)
 out_fp = (checkpoint_dir + ('/checkpoint%d.pickle' % ctr))
 out_fh = open(out_fp, 'w')
 pickle.dump((current_key, ctr, cluster_mapping, ids, bestscores, order), out_fh)
 return out_fp

def write_checkpoint ( current_key , ctr , cluster_mapping , ids , bestscores , order , out_fp ) : checkpoint_dir = ( out_fp + '/checkpoints/' ) if ( not exists ( checkpoint_dir ) ) : create_dir ( checkpoint_dir ) out_fp = ( checkpoint_dir + ( '/checkpoint%d.pickle' % ctr ) ) out_fh = open ( out_fp , 'w' ) pickle . dump ( ( current_key , ctr , cluster_mapping , ids , bestscores , order ) , out_fh ) return out_fp
write intermediate results to checkpoint file current_key: the identifier of the current denoiser round ctr: a uniq counter to label the checkpoint cluster_mapping: an intermediate cluster mapping as dict ids: the dict of active ids order: a list of ids .