code: def generate_test_cases(metric, n):
      """Yields n (y_true, y_pred, sample_weight) triplets for a given metric."""
  
      sample_weights = [random.random() for _ in range(n)]
  
      if isinstance(metric, metrics.base.ClassificationMetric):
          y_true = [random.choice([False, True]) for _ in range(n)]
          if metric.requires_labels:
              y_pred = [random.choice([False, True]) for _ in range(n)]
          else:
              y_pred = [
                  dict(
                      zip(
                          [False, True], np.random.dirichlet(np.ones(2))
                      )
                  )
                  for _ in range(n)
              ]
          yield y_true, y_pred, sample_weights
  
      if isinstance(metric, metrics.base.MultiClassMetric):
          y_true = [random.choice([0, 1, 2]) for _ in range(n)]
          if metric.requires_labels:
              y_pred = [random.choice([0, 1, 2]) for _ in range(n)]
          else:
              y_pred = [
                  dict(zip([0, 1, 2], np.random.dirichlet(np.ones(3))))
                  for _ in range(n)
              ]
          yield y_true, y_pred, sample_weights
  
      if isinstance(metric, metrics.base.RegressionMetric):
          yield (
              [random.random() for _ in range(n)],
              [random.random() for _ in range(n)],
              sample_weights,
          )
  
imports: from __future__ import annotations
  import collections
  import copy
  import functools
  import importlib
  import inspect
  import pickle
  import platform
  import random
  import numpy
  import pytest
  from sklearn import metrics
  from river import metrics, utils
label_desc: Use image node_id 4 for calling a global function with example usage: generate_test_cases(metric, n) without return types