class_docstr: A TestCase mixin for common tests on inference gym targets.
class_docstr_tok: ["A","TestCase","mixin","for","common","tests","on","inference","gym","targets","."]
docstr: Validates the ground truth of a model using forward sampling.
  
  This requires a model to have a `sample` method. This is typically only
  applicable to synthetic models.
  
  Args:
    model: The model to validate. It must have a `sample` method.
    num_samples: Number of samples to generate.
    seed: Optional seed to use. By default, `test_util.test_seed()` is used.
    dtype: DType to use for the algorithm.
docstr_tok: ["Validates","the","ground","truth","of","a","model","using","forward","sampling",".","This","requires","a","model","to","have","a","`","sample","`","method",".","This","is","typically","only","applicable","to","synthetic","models",".","Args",":","model",":","The","model","to","validate",".","It","must","have","a","`","sample","`","method",".","num_samples",":","Number","of","samples","to","generate",".","seed",":","Optional","seed","to","use",".","By","default",",","`","test_util.test_seed","(",")","`","is","used",".","dtype",":","DType","to","use","for","the","algorithm","."]
code: def validate_ground_truth_using_monte_carlo(
      self,
      model,
      num_samples,
      seed=None,
      dtype=tf.float32,
  ):
      """Validates the ground truth of a model using forward sampling.
  
      This requires a model to have a `sample` method. This is typically only
      applicable to synthetic models.
  
      Args:
        model: The model to validate. It must have a `sample` method.
        num_samples: Number of samples to generate.
        seed: Optional seed to use. By default, `test_util.test_seed()` is used.
        dtype: DType to use for the algorithm.
      """
      if seed is None:
          seed = test_util.test_seed()
      samples = model.sample(num_samples, seed=seed)
  
      for (
          name,
          sample_transformation,
      ) in model.sample_transformations.items():
          transformed_samples = self.evaluate(
              tf.identity(sample_transformation(samples))
          )
          nested_num_samples = tf.nest.map_structure(
              lambda _: num_samples, transformed_samples
          )
          self._z_test(
              name=name,
              sample_transformation=sample_transformation,
              transformed_samples=transformed_samples,
              num_samples=nested_num_samples,
              sample_dims=0,
          )
  
imports: import collections
  import importlib
  from absl import flags
  from absl import logging
  import jax
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 3 for calling the InferenceGymTestCase obj's underlying member method code with example usage: obj.validate_ground_truth_using_monte_carlo(model, num_samples, seed, dtype) without return types