docstr: Update the weight of the node given a class and the method used.
  
  Parameters
  ----------
  y
      Class of a given sample.
  dirichlet
      Dirichlet parameter of the tree.
  use_aggregation
      Whether to use aggregation or not during computation (given by the tree).
  step
      Step parameter of the tree.
  n_classes
      The total number of classes of the problem.
docstr_tok: ["Update","the","weight","of","the","node","given","a","class","and","the","method","used",".","Parameters","--","--","--","--","--","y","Class","of","a","given","sample",".","dirichlet","Dirichlet","parameter","of","the","tree",".","use_aggregation","Whether","to","use","aggregation","or","not","during","computation","(","given","by","the","tree",")",".","step","Step","parameter","of","the","tree",".","n_classes","The","total","number","of","classes","of","the","problem","."]
code: def update_weight(
      self,
      y: base.typing.ClfTarget,
      dirichlet: float,
      use_aggregation: bool,
      step: float,
      n_classes: int,
  ) -> float:
      """Update the weight of the node given a class and the method used.
  
      Parameters
      ----------
      y
          Class of a given sample.
      dirichlet
          Dirichlet parameter of the tree.
      use_aggregation
          Whether to use aggregation or not during computation (given by the tree).
      step
          Step parameter of the tree.
      n_classes
          The total number of classes of the problem.
  
      """
  
      loss_t = self.loss(y, dirichlet, n_classes)
      if use_aggregation:
          self.weight -= step * loss_t
      return loss_t
  
imports: from __future__ import annotations
  import collections
  import math
  from river import base, stats
  from river.tree.base import Branch, Leaf
  from river.utils.math import log_sum_2_exp
label_desc: Use image node_id 6 for calling the MondrianNodeClassifier obj's underlying member method code with example usage: obj.update_weight(y, dirichlet, use_aggregation, step, n_classes) and returns: loss_t