code: def testBasic(self, model_class, vec_event_size, batch_shape):
      base_model = model_class()
      vec_model = targets.VectorModel(base_model)
  
      # We can randomize only one element, as otherwise we'd need to know the
      # details of the reshaping/flattening which is outside the scope of this
      # test.
      rand_elem = tf.constant(np.random.randn(), tf.float32)
  
      self.assertEqual("vector_" + base_model.name, vec_model.name)
      self.assertEqual(str(base_model), str(vec_model))
      self.assertEqual(tf.float32, vec_model.dtype)
      self.assertEqual([vec_event_size], list(vec_model.event_shape))
  
      # z - unconstrained space
      structured_z = tf.nest.map_structure(
          lambda s, d, b: tf.fill(  # pylint: disable=g-long-lambda
              batch_shape + list(b.inverse_event_shape(s)),
              tf.cast(rand_elem, d),
          ),
          base_model.event_shape,
          base_model.dtype,
          base_model.default_event_space_bijector,
      )
  
      # x - constrained space
      structured_x = tf.nest.map_structure(
          lambda b, z: b(z),
          base_model.default_event_space_bijector,
          structured_z,
      )
  
      vec_z = tf.fill(
          batch_shape
          + list(
              vec_model.default_event_space_bijector.inverse_event_shape(
                  vec_model.event_shape
              )
          ),
          tf.cast(rand_elem, vec_model.dtype),
      )
      vec_x = vec_model.default_event_space_bijector(vec_z)
  
      # Utility transforms.
      self.assertAllEqualNested(
          structured_x, vec_model.vector_event_to_structured(vec_x)
      )
      self.assertAllEqual(
          vec_x, vec_model.structured_event_to_vector(structured_x)
      )
  
      self.assertAllEqual(
          base_model.unnormalized_log_prob(structured_x),
          vec_model.unnormalized_log_prob(vec_x),
      )
      self.assertAllEqualNested(
          base_model.sample_transformations["first_moment"](
              structured_x
          ),
          vec_model.sample_transformations["first_moment"](vec_x),
      )
      self.assertAllEqualNested(
          base_model.sample_transformations["second_moment"](
              structured_x
          ),
          vec_model.sample_transformations["second_moment"](vec_x),
      )
  
      # Verify that generating values directly from the vector event space works
      # as well.
      vec_x = tf.zeros(
          batch_shape + vec_model.event_shape, vec_model.dtype
      )
      self.assertAllEqual(
          batch_shape, vec_model.unnormalized_log_prob(vec_x).shape
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  from tensorflow_probability.python.internal import test_util
  from inference_gym import targets
  from inference_gym.internal import test_util
label_desc: Use image node_id 1 for calling the VectorModelTest obj's underlying member method code with example usage: obj.testBasic(model_class, vec_event_size, batch_shape) without return types