code: def testShapeCompatibility(self):
      # This test needs a placeholder which means we need to construct a graph.
      with ops.Graph().as_default():
          unknown = array_ops.placeholder(dtypes.int64)
          partial = array_ops.placeholder(dtypes.int64, shape=[None, 1])
          full = array_ops.placeholder(dtypes.int64, shape=[2, 3])
          rank3 = array_ops.placeholder(dtypes.int64, shape=[4, 5, 6])
  
          desc_unknown = tensor.TensorSpec(None, dtypes.int64)
          self.assertTrue(desc_unknown.is_compatible_with(unknown))
          self.assertTrue(desc_unknown.is_compatible_with(partial))
          self.assertTrue(desc_unknown.is_compatible_with(full))
          self.assertTrue(desc_unknown.is_compatible_with(rank3))
  
          desc_partial = tensor.TensorSpec([2, None], dtypes.int64)
          self.assertTrue(desc_partial.is_compatible_with(unknown))
          self.assertTrue(desc_partial.is_compatible_with(partial))
          self.assertTrue(desc_partial.is_compatible_with(full))
          self.assertFalse(desc_partial.is_compatible_with(rank3))
  
          desc_full = tensor.TensorSpec([2, 3], dtypes.int64)
          self.assertTrue(desc_full.is_compatible_with(unknown))
          self.assertFalse(desc_full.is_compatible_with(partial))
          self.assertTrue(desc_full.is_compatible_with(full))
          self.assertFalse(desc_full.is_compatible_with(rank3))
  
          desc_rank3 = tensor.TensorSpec([4, 5, 6], dtypes.int64)
          self.assertTrue(desc_rank3.is_compatible_with(unknown))
          self.assertFalse(desc_rank3.is_compatible_with(partial))
          self.assertFalse(desc_rank3.is_compatible_with(full))
          self.assertTrue(desc_rank3.is_compatible_with(rank3))
  
imports: import pickle
  from absl.testing import parameterized
  import numpy
  from tensorflow.core.framework import full_type_pb2
  from tensorflow.core.function import trace_type
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.framework import type_spec
  from tensorflow.python.framework.type_utils import fulltypes_for_flat_tensors
  from tensorflow.python.ops import array_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 5 for calling the TensorSpecTest obj's underlying member method code with example usage: obj.testShapeCompatibility() without return types