tensor.ndim not working in tensorflow.function decorator
Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59712">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59712">No</a>

Tensorflow Version -> v2.11.0-rc2-17-gd5b57ca93e5,  2.11.0
Custom Code -> Yes
OS Platform and Distribution -> Google colab 

### Standalone code to reproduce the issue

```python3
import tensorflow as tf

tensor=tf.random.normal((32,128,128,3))                                         # some images 
print('Work here->',tensor.ndim)

@tf.function
def some_function(images):
  #assert images.ndim==4                                                                # not working here also 
  # some complex code 
  print('NOT working here->',images.ndim)

some_function(tensor)
```

### Relevant log output

```shell
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-247-f1adf673db7a>](https://localhost:8080/#) in <module>
     10   print('NOT working here->',images.ndim)
     11 
---> 12 some_function(tensor)

1 frames
[/usr/local/lib/python3.8/dist-packages/tensorflow/python/util/traceback_utils.py](https://localhost:8080/#) in error_handler(*args, **kwargs)
    151     except Exception as e:
    152       filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153       raise e.with_traceback(filtered_tb) from None
    154     finally:
    155       del filtered_tb

[/tmp/__autograph_generated_filesflyrml3.py](https://localhost:8080/#) in tf__some_function(images)
      6         def tf__some_function(images):
      7             with ag__.FunctionScope('some_function', 'fscope', ag__.ConversionOptions(recursive=True, user_requested=True, optional_features=(), internal_convert_user_code=True)) as fscope:
----> 8                 ag__.ld(print)('NOT working here->', ag__.ld(images).ndim)
      9         return tf__some_function
     10     return inner_factory

AttributeError: in user code:

    File "<ipython-input-246-0cf28125d885>", line 10, in some_function  *
        print('NOT working here->',images.ndim)

    AttributeError: 'Tensor' object has no attribute 'ndim'
```