def define_graph(inputs, labels, is_training, batch_size, replicas_to_aggregate):
    '\n    Define graph for synchronized training.\n    '
    model = Cifar10Model(resnet_size=20, data_format='channels_last', resnet_version=2, dtype=tf.float32)
    logits = model(inputs, is_training)
    loss = softmax_cross_entropy_with_logits_v2_l2_regularized(logits=logits, labels=labels, l2=0.0002, loss_filter_fn=(lambda name: ('batch_normalization' not in name)))
    metrics = [TopKAccuracy(logits, labels, topk=1), TopKAccuracy(logits, labels, topk=5)]
    global_step = tf.train.get_or_create_global_step()
    lr_scheduler = manual_stepping(global_step=global_step, boundaries=[(32000 // replicas_to_aggregate), (48000 // replicas_to_aggregate)], rates=[0.1, 0.01, 0.001], warmup=False)
    optimizer_ = tf.train.MomentumOptimizer(learning_rate=lr_scheduler, momentum=0.9, use_nesterov=True)
    optimizer = tf.train.SyncReplicasOptimizer(optimizer_, replicas_to_aggregate=replicas_to_aggregate, total_num_replicas=replicas_to_aggregate)
    hooks = [optimizer.make_session_run_hook((rank == 0), num_tokens=0)]
    update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
    with tf.control_dependencies(update_ops):
        grads_and_vars = list(optimizer.compute_gradients(loss, tf.trainable_variables()))
        train_op = optimizer.apply_gradients(grads_and_vars, global_step=global_step)
    return (train_op, loss, metrics, hooks)
Define graph for synchronized training.
def define_graph(inputs, labels, is_training, batch_size, replicas_to_aggregate):
    '\n    \n    '
    model = Cifar10Model(resnet_size=20, data_format='channels_last', resnet_version=2, dtype=tf.float32)
    logits = model(inputs, is_training)
    loss = softmax_cross_entropy_with_logits_v2_l2_regularized(logits=logits, labels=labels, l2=0.0002, loss_filter_fn=(lambda name: ('batch_normalization' not in name)))
    metrics = [TopKAccuracy(logits, labels, topk=1), TopKAccuracy(logits, labels, topk=5)]
    global_step = tf.train.get_or_create_global_step()
    lr_scheduler = manual_stepping(global_step=global_step, boundaries=[(32000 // replicas_to_aggregate), (48000 // replicas_to_aggregate)], rates=[0.1, 0.01, 0.001], warmup=False)
    optimizer_ = tf.train.MomentumOptimizer(learning_rate=lr_scheduler, momentum=0.9, use_nesterov=True)
    optimizer = tf.train.SyncReplicasOptimizer(optimizer_, replicas_to_aggregate=replicas_to_aggregate, total_num_replicas=replicas_to_aggregate)
    hooks = [optimizer.make_session_run_hook((rank == 0), num_tokens=0)]
    update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
    with tf.control_dependencies(update_ops):
        grads_and_vars = list(optimizer.compute_gradients(loss, tf.trainable_variables()))
        train_op = optimizer.apply_gradients(grads_and_vars, global_step=global_step)
    return (train_op, loss, metrics, hooks)