code: def check_predict_proba_one(classifier, dataset):
      """predict_proba_one should return a valid probability distribution and be pure."""
  
      from river import utils
  
      if not hasattr(classifier, "predict_proba_one"):
          return
  
      for x, y in dataset:
          xx, yy = copy.deepcopy(x), copy.deepcopy(y)
  
          classifier.learn_one(x, y)
          y_pred = classifier.predict_proba_one(x)
  
          if utils.inspect.isactivelearner(classifier):
              y_pred, _ = y_pred
  
          # Check the probabilities are coherent
          assert isinstance(y_pred, dict)
          for proba in y_pred.values():
              assert 0.0 <= proba <= 1.0
          assert math.isclose(sum(y_pred.values()), 1.0)
  
          # Check predict_proba_one is pure (i.e. x and y haven't changed)
          assert x == xx
          assert y == yy
  
imports: from __future__ import annotations
  import copy
  import math
label_desc: Use image node_id 1 for calling a global function with example usage: check_predict_proba_one(classifier, dataset) without return types