def _optimize_clone(optimizer, clone, num_clones, regularization_losses, **kwargs):
 sum_loss = _gather_clone_loss(clone, num_clones, regularization_losses)
 clone_grad = None
 if (sum_loss is not None):
  with tf.device(clone.device):
   clone_grad = optimizer.compute_gradients(sum_loss, **kwargs)
 return (sum_loss, clone_grad)

def _optimize_clone ( optimizer , clone , num_clones , regularization_losses , ** kwargs ) : sum_loss = _gather_clone_loss ( clone , num_clones , regularization_losses ) clone_grad = None if ( sum_loss is not None ) : with tf . device ( clone . device ) : clone_grad = optimizer . compute_gradients ( sum_loss , ** kwargs ) return ( sum_loss , clone_grad )
compute losses and gradients for a single clone .