code: def chi_squared(x, bins):
      """Pearson's Chi-squared test."""
      x = np.ravel(x)
      n = len(x)
      histogram, _ = np.histogram(x, bins=bins, range=(0, 1))
      expected = n / float(bins)
      return np.sum(np.square(histogram - expected) / expected)
  
imports: import math
  import numpy
  from tensorflow.python.ops.distributions import special_math
label_desc: Use image node_id 2 for calling a global function with example usage: chi_squared(x, bins) and returns: np