code: def _histogram_mode(X, num_bins, smin, smax):
      bin_width = (smax - smin) / num_bins
  
      if bin_width == 0:
          return np.nan
  
      histogram = np.zeros(num_bins)
      for val in X:
          idx = int((val - smin) / bin_width)
          idx = num_bins - 1 if idx >= num_bins else idx
          histogram[idx] += 1
  
      edges = np.zeros(num_bins + 1, dtype=np.float32)
      for i in range(len(edges)):
          edges[i] = i * bin_width + smin
  
      max_count = 0
      num_maxs = 1
      max_sum = 0
      for i in range(num_bins):
          v = (edges[i] + edges[i + 1]) / 2
          if histogram[i] > max_count:
              max_count = histogram[i]
              num_maxs = 1
              max_sum = v
          elif histogram[i] == max_count:
              num_maxs += 1
              max_sum += v
  
      return max_sum / num_maxs
  
imports: import math
  import numpy
  from sktime.utils.numba.njit import njit
label_desc: Use image node_id 1 for calling a global function with example usage: _histogram_mode(X, num_bins, smin, smax) and returns: unknown, np