code: def test_validation(self):
      b, h = 2, 3
  
      for fw in FRAMEWORKS_TO_TEST:
          double_type = DOUBLE_TYPE[fw]
          float_type = FLOAT_TYPE[fw]
  
          tensor_2d = TensorSpec(
              "b,h", b=b, h=h, framework=fw, dtype=double_type
          ).fill()
  
          matching_specs = [
              TensorSpec("b,h", framework=fw),
              TensorSpec("b,h", h=h, framework=fw),
              TensorSpec("b,h", h=h, b=b, framework=fw),
              TensorSpec("b,h", b=b, framework=fw, dtype=double_type),
          ]
  
          # check if get_shape returns a tuple of ints
          shape = matching_specs[0].get_shape(tensor_2d)
          self.assertIsInstance(shape, tuple)
          print(fw)
          print(shape)
          self.assertTrue(all(isinstance(x, int) for x in shape))
  
          # check matching
          for spec in matching_specs:
              spec.validate(tensor_2d)
  
          non_matching_specs = [
              TensorSpec("b", framework=fw),
              TensorSpec("b,h1,h2", framework=fw),
              TensorSpec("b,h", h=h + 1, framework=fw),
          ]
          if fw != "jax":
              non_matching_specs.append(
                  TensorSpec("b,h", framework=fw, dtype=float_type)
              )
  
          for spec in non_matching_specs:
              self.assertRaises(
                  ValueError, lambda: spec.validate(tensor_2d)
              )
  
          # non unique dimensions
          self.assertRaises(
              ValueError, lambda: TensorSpec("b,b", framework=fw)
          )
          # unknown dimensions
          self.assertRaises(
              ValueError,
              lambda: TensorSpec("b,h", b=1, h=2, c=3, framework=fw),
          )
          self.assertRaises(
              ValueError, lambda: TensorSpec("b1", b2=1, framework=fw)
          )
          # zero dimensions
          self.assertRaises(
              ValueError,
              lambda: TensorSpec("b,h", b=1, h=0, framework=fw),
          )
          # non-integer dimension
          self.assertRaises(
              ValueError,
              lambda: TensorSpec("b,h", b=1, h="h", framework=fw),
          )
  
file_path: ray/python/ray/rllib/core/models/specs/tests/test_tensor_spec.py
imports: import itertools
  import unittest
  import numpy
  from ray.rllib.utils import try_import_jax, try_import_tf, try_import_torch
  from ray.rllib.utils.test_utils import check
  from ray.rllib.core.models.specs.specs_base import TensorSpec
label_desc: Use image node_id 3 for calling the TestSpecs obj's underlying member method code with example usage: obj.test_validation() without return types