code: def _entropy(cm, y_true):
      n_samples = cm.n_samples
      if n_samples == 0:
          return 1.0
  
      if y_true:
          values = cm.sum_row
      else:
          values = cm.sum_col
      entropy = 0.0
      for i in cm.classes:
          if i in values and values[i] > 0:
              entropy -= (values[i] / n_samples) * (
                  np.log(values[i]) - np.log(n_samples)
              )
      return entropy
  
imports: from __future__ import annotations
  import math
  import numpy
  from river import metrics
  from river.metrics.expected_mutual_info import expected_mutual_info
label_desc: Use image node_id 1 for calling a global function with example usage: _entropy(cm, y_true) and returns: entropy, int