code: def unif01_goodness_of_fit(samples, *, plot=False):
      """
      Bin uniformly distributed samples and apply Pearson's chi^2 test.
  
      :param torch.Tensor samples: A vector of real-valued samples from a
          candidate distribution that should be Uniform(0, 1)-distributed.
      :param bool plot: Whether to print a histogram. Defaults to False.
      :returns: Goodness of fit, as a p-value.
      :rtype: float
      """
      assert samples.min() >= 0
      assert samples.max() <= 1
      bin_count = int(round(len(samples) ** 0.333))
      if bin_count < 7:
          raise InvalidTest("imprecise test, use more samples")
      probs = torch.ones(bin_count) / bin_count
      binned = (
          samples.mul(bin_count).long().clamp(min=0, max=bin_count - 1)
      )
      counts = torch.zeros(bin_count)
      counts.scatter_add_(0, binned, torch.ones(binned.shape))
      return multinomial_goodness_of_fit(probs, counts, plot=plot)
  
file_path: pyro/pyro/distributions/testing/gof.py
imports: import math
  import warnings
  import torch
  from .special import chi2sf
label_desc: Use image node_id 3 for calling a global function with example usage: unif01_goodness_of_fit(samples) and returns: multinomial_goodness_of_fit