code: def vector_density_goodness_of_fit(
      samples, probs, *, dim=None, plot=False
  ):
      """
      Transform arbitrary multivariate continuous samples to Univariate(0,1)
      distribution via nearest neighbor distribution [1,2,3] and assess goodness
      of fit via binned Pearson's chi^2 test.
  
      [1] Peter J. Bickel and Leo Breiman (1983)
          "Sums of Functions of Nearest Neighbor Distances, Moment Bounds, Limit
          Theorems and a Goodness of Fit Test"
          https://projecteuclid.org/download/pdf_1/euclid.aop/1176993668
      [2] Mike Williams (2010)
          "How good are your fits? Unbinned multivariate goodness-of-fit tests in
          high energy physics."
          https://arxiv.org/abs/1006.3019
      [3] Nearest Neighbour Distribution
          https://en.wikipedia.org/wiki/Nearest_neighbour_distribution
  
      :param torch.Tensor samples: A tensor of real-vector-valued samples from a
          distribution.
      :param torch.Tensor probs: A vector of probability densities evaluated at
          those samples.
      :param int dim: Optional dimension of the submanifold on which data lie.
          Defaults to ``samples.shape[-1]``.
      :param bool plot: Whether to print a histogram. Defaults to False.
      :returns: Goodness of fit, as a p-value.
      :rtype: float
      """
      assert samples.shape and len(samples)
      assert probs.shape == samples.shape[:1]
      if dim is None:
          dim = samples.shape[-1]
      assert dim
      if len(samples) <= 1000 * dim:
          raise InvalidTest("imprecision; use more samples")
      radii = get_nearest_neighbor_distances(samples)
      density = len(samples) * probs
      volume = volume_of_sphere(dim, radii)
      exp_samples = density * volume
      return exp_goodness_of_fit(exp_samples, 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 8 for calling a global function with example usage: vector_density_goodness_of_fit(samples, probs) and returns: exp_goodness_of_fit