code: def optimizer_update(
      w: Union[ivy.Array, ivy.NativeArray],
      effective_grad: Union[ivy.Array, ivy.NativeArray],
      lr: Union[float, ivy.Array, ivy.NativeArray],
      /,
      *,
      stop_gradients: bool = True,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Update weights ws of some function, given the true or effective
      derivatives of some cost c with respect to ws, [dc/dw for w in ws].
  
      Parameters
      ----------
      w
          Weights of the function to be updated.
      effective_grad
          Effective gradients of the cost c with respect to the weights ws,
          [dc/dw for w in ws].
      lr
          Learning rate(s), the rate(s) at which the weights should be updated relative to
          the gradient.
      stop_gradients
          Whether to stop the gradients of the variables after each gradient step.
          Default is ``True``.
      out
          optional output array, for writing the result to. It must have a shape that the
          inputs broadcast to.
  
      Returns
      -------
      ret
          The new function weights ws_new, following the optimizer updates.
  
      Examples
      --------
      With :class:`ivy.Array` inputs:
  
      >>> w = ivy.array([1., 2., 3.])
      >>> effective_grad = ivy.zeros(3)
      >>> lr = 3e-4
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr)
      >>> print(ws_new)
      ivy.array([1., 2., 3.])
  
      >>> w = ivy.array([1., 2., 3.])
      >>> effective_grad = ivy.zeros(3)
      >>> lr = 3e-4
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr,
      ...                               out=None, stop_gradients=True)
      >>> print(ws_new)
      ivy.array([1., 2., 3.])
  
      >>> w = ivy.array([[1., 2.], [4., 5.]])
      >>> out = ivy.zeros_like(w)
      >>> effective_grad = ivy.array([[4., 5.], [7., 8.]])
      >>> lr = ivy.array([3e-4, 1e-2])
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr, out=out)
      >>> print(out)
      ivy.array([[0.999, 1.95],
                 [4., 4.92]])
  
      >>> w = ivy.array([1., 2., 3.])
      >>> out = ivy.zeros_like(w)
      >>> effective_grad = ivy.array([4., 5., 6.])
      >>> lr = ivy.array([3e-4])
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr,
      ...                               stop_gradients=False, out=out)
      >>> print(out)
      ivy.array([0.999, 2.   , 3.   ])
  
      With one :class:`ivy.Container` input:
  
      >>> w = ivy.Container(a=ivy.array([0., 1., 2.]),
      ...                   b=ivy.array([3., 4., 5.]))
      >>> effective_grad = ivy.array([0., 0., 0.])
      >>> lr = 3e-4
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr)
      >>> print(ws_new)
      {
          a: ivy.array([0., 1., 2.]),
          b: ivy.array([3., 4., 5.])
      }
  
      With multiple :class:`ivy.Container` inputs:
  
      >>> w = ivy.Container(a=ivy.array([0., 1., 2.]),
      ...                   b=ivy.array([3., 4., 5.]))
      >>> effective_grad = ivy.Container(a=ivy.array([0., 0., 0.]),
      ...                                b=ivy.array([0., 0., 0.]))
      >>> lr = 3e-4
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr, out=w)
      >>> print(w)
      {
          a: ivy.array([0., 1., 2.]),
          b: ivy.array([3., 4., 5.])
      }
  
      >>> w = ivy.Container(a=ivy.array([0., 1., 2.]),
      ...                   b=ivy.array([3., 4., 5.]))
      >>> effective_grad = ivy.Container(a=ivy.array([0., 0., 0.]),
      ...                                b=ivy.array([0., 0., 0.]))
      >>> lr = ivy.array([3e-4])
      >>> ws_new = ivy.optimizer_update(w, effective_grad, lr,
      ...                               stop_gradients=False)
      >>> print(ws_new)
      {
          a: ivy.array([0., 1., 2.]),
          b: ivy.array([3., 4., 5.])
      }
      """
      deltas = effective_grad * lr
      w = ivy.subtract(w, deltas, out=out)
      if stop_gradients:
          return ivy.stop_gradient(w, preserve_type=True, out=out)
      return w
  
imports: from typing import Sequence, Union, Optional, Tuple, Callable
  import numpy
  import itertools
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, inputs_to_ivy_arrays, to_native_arrays_and_back, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 26 for calling a global function with example usage: optimizer_update() and returns: w, ivy