code: def auto_goodness_of_fit(samples, probs, *, dim=None, plot=False):
      """
      Dispatch on sample dimension and delegate to either
      :func:`density_goodness_of_fit` or :func:`vector_density_goodness_of_fit`.
  
      :param torch.Tensor samples: A tensor of samples stacked on their leftmost
          dimension.
      :param torch.Tensor probs: A vector of probabilities evaluated at those
          samples.
      :param int dim: Optional manifold dimension, defaults to
          ``samples.shape[1:].numel()``.
      :param bool plot: Whether to print a histogram. Defaults to False.
      """
      assert samples.shape and samples.shape[0]
      assert probs.shape == samples.shape[:1]
  
      samples = samples.reshape(samples.shape[0], -1)
      ambient_dim = samples.shape[1:].numel()
      if dim is None:
          dim = ambient_dim
  
      if ambient_dim == 0:
          return 1.0
      if ambient_dim == 1:
          samples = samples.reshape(-1)
          return density_goodness_of_fit(samples, probs, plot=plot)
      return vector_density_goodness_of_fit(
          samples, probs, dim=dim, 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 9 for calling a global function with example usage: auto_goodness_of_fit(samples, probs) and returns: vector_density_goodness_of_fit, int, density_goodness_of_fit