AttributeError: 'Tensor' object has no attribute 'shape' when using TensorFlow 2.12 with tf.function
I'm working with an `AttributeError` when trying to access the shape of a TensorFlow tensor inside a `tf.function`. Specifically, the behavior message states: `AttributeError: 'Tensor' object has no attribute 'shape'`. Here's a simplified version of my code: ```python import tensorflow as tf @tf.function def example_function(x): print(x.shape) # This line causes the behavior return tf.reduce_sum(x) input_tensor = tf.constant([[1.0, 2.0], [3.0, 4.0]]) result = example_function(input_tensor) ``` When I run this code, I expected it to print the shape of the input tensor and return the sum of its elements. Instead, I get the `AttributeError`. I have tried modifying the print statement to use `tf.shape(x)`, but then I receive a different message indicating that `tf.shape` does not behave as expected within `tf.function`. I also checked if enabling eager execution would resolve the scenario, but it seems to alter how my graphs are executed and does not work with my current workflow. Has anyone else faced this scenario when using `tf.function` in TensorFlow 2.12, and what would be the best way to access tensor shapes inside a compiled function? Any insights would be greatly appreciated!