def _accumulate_gradients(self, per_replica_features, per_replica_labels):
    'Accumulates the gradients across all the replica.'
    per_replica_loss = self.args.strategy.experimental_run_v2(self._forward, args=(per_replica_features, per_replica_labels))
    try:
        reduced_loss = self.args.strategy.reduce(tf.distribute.ReduceOp.MEAN, per_replica_loss, axis=0)
    except ValueError:
        reduced_loss = self.args.strategy.reduce(tf.distribute.ReduceOp.MEAN, per_replica_loss, None)
    return reduced_loss
Accumulates the gradients across all the replica.
def _accumulate_gradients(self, per_replica_features, per_replica_labels):
    
    per_replica_loss = self.args.strategy.experimental_run_v2(self._forward, args=(per_replica_features, per_replica_labels))
    try:
        reduced_loss = self.args.strategy.reduce(tf.distribute.ReduceOp.MEAN, per_replica_loss, axis=0)
    except ValueError:
        reduced_loss = self.args.strategy.reduce(tf.distribute.ReduceOp.MEAN, per_replica_loss, None)
    return reduced_loss