class_docstr: Tests ModelV2 classes and their modularization capabilities.
class_docstr_tok: ["Tests","ModelV2","classes","and","their","modularization","capabilities","."]
code: def test_tf_modelv2(self):
      obs_space = Box(-1.0, 1.0, (3,))
      action_space = Box(-1.0, 1.0, (2,))
      my_tf_model = TestTFModel(
          obs_space, action_space, 5, {}, "my_tf_model"
      )
      # Call the model.
      out, states = my_tf_model({"obs": np.array([obs_space.sample()])})
      self.assertTrue(out.shape == (1, 5))
      self.assertTrue(out.dtype == tf.float32)
      self.assertTrue(states == [])
      vars = my_tf_model.variables(as_dict=True)
      self.assertTrue(len(vars) == 6)
      self.assertTrue("keras_model.dense.kernel:0" in vars)
      self.assertTrue("keras_model.dense.bias:0" in vars)
      self.assertTrue("fc_net.base_model.fc_out.kernel:0" in vars)
      self.assertTrue("fc_net.base_model.fc_out.bias:0" in vars)
      self.assertTrue("fc_net.base_model.value_out.kernel:0" in vars)
      self.assertTrue("fc_net.base_model.value_out.bias:0" in vars)
  
file_path: ray/python/ray/rllib/models/tests/test_models.py
imports: from gymnasium.spaces import Box
  import numpy
  import unittest
  import ray
  import ray.rllib.algorithms.ppo
  from ray.rllib.examples.models.modelv3 import RNNModel
  from ray.rllib.models.tf.tf_modelv2 import TFModelV2
  from ray.rllib.models.tf.fcnet import FullyConnectedNetwork
  from ray.rllib.utils.framework import try_import_tf
label_desc: Use image node_id 3 for calling the TestModels obj's underlying member method code with example usage: obj.test_tf_modelv2() without return types