docstr: 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
  ----------
  self
      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 container, 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 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 = w.optimizer_update(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 = w.optimizer_update(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 = w.optimizer_update(effective_grad, lr, stop_gradients=False)
  >>> print(ws_new)
  {
      a: ivy.array([0., 1., 2.]),
      b: ivy.array([3., 4., 5.])
  }
docstr_tok: ["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","--","--","--","--","--","self","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","container",",","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","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","=","w.optimizer_update","(","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","=","w.optimizer_update","(","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","=","w.optimizer_update","(","effective_grad",",","lr",",","stop_gradients=False",")",">",">",">","print","(","ws_new",")","{","a",":","ivy.array","(","[","0.",",","1.",",","2",".","]",")",",","b",":","ivy.array","(","[","3.",",","4.",",","5",".","]",")","}"]
code: def optimizer_update(
      self: ivy.Container,
      effective_grad: Union[ivy.Array, ivy.NativeArray, ivy.Container],
      lr: Union[float, ivy.Array, ivy.NativeArray, ivy.Container],
      /,
      *,
      stop_gradients: Union[bool, ivy.Container] = True,
      out: Optional[ivy.Container] = None,
  ) -> ivy.Container:
      """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
      ----------
      self
          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 container, 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 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 = w.optimizer_update(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 = w.optimizer_update(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 = w.optimizer_update(effective_grad, lr, stop_gradients=False)
      >>> print(ws_new)
      {
          a: ivy.array([0., 1., 2.]),
          b: ivy.array([3., 4., 5.])
      }
      """
      return ivy.optimizer_update(
          self,
          effective_grad,
          lr,
          stop_gradients=stop_gradients,
          out=out,
      )
  
file_path: ivy/ivy/data_classes/container/gradients.py
imports: from typing import Optional, Union, List, Dict
  import ivy
  from ivy.data_classes.container.base import ContainerBase
label_desc: Use image node_id 4 for calling the _ContainerWithGradients obj's underlying member method code with example usage: obj.optimizer_update() and returns: ivy