def METHOD_NAME(
    self, distribution, grads_and_vars, **kwargs
):
    """`apply_gradients` using a `DistributionStrategy`."""
    def apply_grad_to_update_var(var, grad):
        learning_rate = self._get_current_learning_rate()
        grad = tf.convert_to_tensor(grad)
        return self.update_step(grad, var, learning_rate)
    for grad, var in grads_and_vars:
        distribution.extended.update(
            var, apply_grad_to_update_var, args=(grad,), group=False
        )
    if self.use_ema:
        _, var_list = zip(*grads_and_vars)
        self._update_model_variables_moving_average(var_list)
        if self.ema_overwrite_frequency:
            # Only when self.ema_overwrite_frequency is not None, we
            # overwrite the model variables.
            should_overwrite_model_vars = (
                self.iterations + 1
            ) % self.ema_overwrite_frequency == 0
            tf.cond(
                tf.cast(should_overwrite_model_vars, tf.bool),
                true_fn=lambda: self._overwrite_model_variables_with_average_value(  # noqa: E501
                    var_list
                ),
                false_fn=lambda: None,
            )
    self.iterations.assign(self.iterations + 1)