docstr: if not has_applied:
      grad = self.add_regular_to_grad(grad, model_weights)
      delta_grad = self.apply_gradients(grad)
  else:
docstr_tok: ["if","not","has_applied",":","grad","=","self.add_regular_to_grad","(","grad",",","model_weights",")","delta_grad","=","self.apply_gradients","(","grad",")","else",":"]
code: def update_weights(
      self,
      model_weights,
      grad,
      fit_intercept,
      lr,
      prev_round_weights=None,
      has_applied=True,
  ):
      """if not has_applied:
          grad = self.add_regular_to_grad(grad, model_weights)
          delta_grad = self.apply_gradients(grad)
      else:"""
      # logger.info(
      #     f"before update, model weights: {model_weights}, delta_grad: {grad}")
      delta_grad = grad
      model_weights = self.regularization_update(
          model_weights,
          delta_grad,
          fit_intercept,
          lr,
          prev_round_weights,
      )
      # (f"after update, model weights: {model_weights}")
  
      return model_weights
  
imports: import logging
  import numpy
  import torch
label_desc: Use image node_id 15 for calling the Optimizer obj's underlying member method code with example usage: obj.update_weights(model_weights, grad, fit_intercept, lr, prev_round_weights, has_applied) and returns: model_weights