code: def test_mutate():
      """
  
      >>> from river import datasets, linear_model, optim, preprocessing
  
      >>> model = (
      ...     preprocessing.StandardScaler() |
      ...     linear_model.LinearRegression(
      ...         optimizer=optim.SGD(3e-2)
      ...     )
      ... )
  
      >>> for x, y in datasets.TrumpApproval():
      ...     _ = model.predict_one(x)
      ...     model.learn_one(x, y)
  
      >>> len(model[-1].weights)
      6
  
      >>> model.mutate({'LinearRegression': {'optimizer': {'lr': {'learning_rate': 42}}}})
      >>> model[-1].optimizer
      SGD({'lr': Constant({'learning_rate': 42}), 'n_iterations': 1001})
  
      >>> model.mutate({'LinearRegression': {'optimizer': {'lr': optim.schedulers.Constant(43)}}})
      >>> model[-1].optimizer
      SGD({'lr': Constant({'learning_rate': 43}), 'n_iterations': 1001})
  
      >>> model.mutate({'LinearRegression': {'optimizer': optim.SGD(44)}})
      >>> model[-1].optimizer
      SGD({'lr': Constant({'learning_rate': 44}), 'n_iterations': 0})
  
      >>> model.mutate({'LinearRegression': {'l2': 0.123}})
      >>> model[-1].l2
      0.123
  
      >>> len(model[-1].weights)
      6
  
      >>> try:
      ...     model.mutate({'LinearRegression': {'weights': 'this is weird'}})
      ... except ValueError as e:
      ...     print(e)
      'weights' is not a mutable attribute of LinearRegression
  
      >>> try:
      ...     model.mutate({'LinearRegression': {'l3': 123}})
      ... except ValueError as e:
      ...     print(e)
      'l3' is not an attribute of LinearRegression
  
      """
  
file_path: river/river/base/test_base.py
imports: from __future__ import annotations
  from river import compose, datasets, linear_model, optim, preprocessing, stats, time_series
label_desc: Use image node_id 6 for calling a global function with example usage: test_mutate() without return types