TensorShape is (None, None, None) on images
The following preprocess function doesn't work either:

```
def preprocess(file_name):
    x = tf.io.read_file(file_name)
    x = tf.io.decode_jpeg(x)
    
    new_size = tf.cast(tf.divide(x.shape,2))[:2]
    tf.print(new_size)
    x = tf.image.resize(x, new_size)
    x = tf.image.random_crop(x, (32,32,3))
    
    return x, tf.zeros_like(x)
```

```
ValueError: in user code:

    File "/tmp/ipykernel_583425/4093202739.py", line 8, in preprocess  *
        new_size = tf.cast(tf.divide(x.shape,2))[:2]

    ValueError: Cannot convert a partially known TensorShape (None, None, None) to a Tensor.

``` @ngbusca  If instead of `x.shape`, if you use `x_shape = tf.shape(x)`, does it help you out ? 

So, 
```
def preprocess(file_name):
    x = tf.io.read_file(file_name)
    x = tf.io.decode_jpeg(x)
    
    nrows, ncols,_ = x.shape
    
    x = tf.image.resize(x, (nrows//2, ncols//2))
    
    x = tf.image.random_crop(x, (32,32,3))
    
    return x, tf.zeros_like(x)
```
becomes 

```
def preprocess(file_name):
    x = tf.io.read_file(file_name)
    x = tf.io.decode_jpeg(x)
    
    x_shape = tf.shape(x)
    
    x = tf.image.resize(x, (x_shape[0]//2, x_shape[1]//2))

    
    x = tf.image.random_crop(x, (32,32,3))
    
    return x, tf.zeros_like(x)
```
 Hi @ujjwalnur yes, amazing this works:

```
def preprocess(file_name):
    x = tf.io.read_file(file_name)
    x = tf.io.decode_jpeg(x)

    new_size = tf.cast(tf.divide(tf.shape(x),2), tf.int32)[:2]
    
    x = tf.image.resize(x, new_size)
    x = tf.image.random_crop(x, (32,32,3))
    
    return x, tf.zeros_like(x)
```

Is `x.shape` expected to behave differently from `tf.shape(x)` ? @ngbusca 

`x.shape` is trying to give you the static shape of the tensor which is not known. All preprocessing stages of a dataset run in graph mode. So, `x.shape` is `None`. `tf.shape` gives you the dynamic shape which can be computed during runtime and so the error disappears. Thanks, I'll close the issue 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/62183">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/62183">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

2.13

### Custom code

Yes

### OS platform and distribution

_No response_

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

An I/O pipeline for images using Dataset reads images into tensor but the shape is (None, None, None), preventing some applications that need the tensor shape further down in preprocessing (for example, resizing the image by a factor).

In the example below I can get by by recovering the image dimensions with a trick but it feels very *very* hacky. Is there a reason why the shape should be None?

### Standalone code to reproduce the issue

```shell
def preprocess(file_name):
    x = tf.io.read_file(file_name)
    x = tf.io.decode_jpeg(x)
    
    nrows, ncols,_ = x.shape
    
    x = tf.image.resize(x, (nrows//2, ncols//2))
    
    x = tf.image.random_crop(x, (32,32,3))
    
    return x, tf.zeros_like(x)

def preprocess_workaround(file_name):
    x = tf.io.read_file(file_name)
    x = tf.io.decode_jpeg(x)
    
    nrows = tf.math.reduce_sum(tf.ones_like(x[:,0], dtype=tf.int32))
    ncols = tf.math.reduce_sum(tf.ones_like(x[0,:], dtype=tf.int32))
    
    x = tf.image.resize(x, (nrows//2, ncols//2))
    
    x = tf.image.random_crop(x, (32,32,3))
    
    return x, tf.zeros_like(x)

model = tf.keras.models.Sequential()
model.add(tf.keras.Input(shape=(32,32,3)))
model.add(tf.keras.layers.Conv2D(3, (3,3), padding='same'))
model.summary()

files = glob.glob("/mnt/ng/ncl/acquisition/stitches/20231019/row1/??/1/crop.jpg")
print(len(files))

## crashes with the output below
ds = tf.data.Dataset.from_tensor_slices(files).map(preprocess).batch(1)


## the following works:
## ds = tf.data.Dataset.from_tensor_slices(files).map(preprocess_workaround).batch(1)

model.fit(ds)
```
```


### Relevant log output

```shell
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_583425/761276435.py in <module>
      1 files = glob.glob("/mnt/ng/ncl/acquisition/stitches/20231019/row1/??/1/crop.jpg")
      2 print(len(files))
----> 3 ds = tf.data.Dataset.from_tensor_slices(files).map(preprocess).batch(1)
      4 model.fit(ds)

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/dataset_ops.py in map(self, map_func, num_parallel_calls, deterministic, name)
   2292         warnings.warn("The `deterministic` argument has no effect unless the "
   2293                       "`num_parallel_calls` argument is specified.")
-> 2294       return MapDataset(self, map_func, preserve_cardinality=True, name=name)
   2295     else:
   2296       return ParallelMapDataset(

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/dataset_ops.py in __init__(self, input_dataset, map_func, use_inter_op_parallelism, preserve_cardinality, use_legacy_function, name)
   5497     self._use_inter_op_parallelism = use_inter_op_parallelism
   5498     self._preserve_cardinality = preserve_cardinality
-> 5499     self._map_func = structured_function.StructuredFunctionWrapper(
   5500         map_func,
   5501         self._transformation_name(),

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/structured_function.py in __init__(self, func, transformation_name, dataset, input_classes, input_shapes, input_types, input_structure, add_to_graph, use_legacy_function, defun_kwargs)
    261         fn_factory = trace_tf_function(defun_kwargs)
    262 
--> 263     self._function = fn_factory()
    264     # There is no graph to add in eager mode.
    265     add_to_graph &= not context.executing_eagerly()

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py in get_concrete_function(self, *args, **kwargs)
    224         `tf.Tensor` or `tf.TensorSpec`.
    225     """
--> 226     concrete_function = self._get_concrete_function_garbage_collected(
    227         *args, **kwargs)
    228     concrete_function._garbage_collector.release()  # pylint: disable=protected-access

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py in _get_concrete_function_garbage_collected(self, *args, **kwargs)
    190 
    191     with self._lock:
--> 192       concrete_function, _ = self._maybe_define_concrete_function(args, kwargs)
    193       seen_names = set()
    194       captured = object_identity.ObjectIdentitySet(

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py in _maybe_define_concrete_function(self, args, kwargs)
    155       kwargs = {}
    156 
--> 157     return self._maybe_define_function(args, kwargs)
    158 
    159   def _get_concrete_function_internal_garbage_collected(self, *args, **kwargs):

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py in _maybe_define_function(self, args, kwargs)
    358             args, kwargs = generalized_func_key._placeholder_value()  # pylint: disable=protected-access
    359 
--> 360           concrete_function = self._create_concrete_function(args, kwargs)
    361 
    362           graph_capture_container = concrete_function.graph._capture_func_lib  # pylint: disable=protected-access

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py in _create_concrete_function(self, args, kwargs)
    282     arg_names = base_arg_names + missing_arg_names
    283     concrete_function = monomorphic_function.ConcreteFunction(
--> 284         func_graph_module.func_graph_from_py_func(
    285             self._name,
    286             self._python_function,

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, acd_record_initial_resource_uses)
   1281         _, original_func = tf_decorator.unwrap(python_func)
   1282 
-> 1283       func_outputs = python_func(*func_args, **func_kwargs)
   1284 
   1285       # invariant: `func_outputs` contains only Tensors, CompositeTensors,

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/structured_function.py in wrapped_fn(*args)
    238           attributes=defun_kwargs)
    239       def wrapped_fn(*args):  # pylint: disable=missing-docstring
--> 240         ret = wrapper_helper(*args)
    241         ret = structure.to_tensor_list(self._output_structure, ret)
    242         return [ops.convert_to_tensor(t) for t in ret]

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/structured_function.py in wrapper_helper(*args)
    169       if not _should_unpack(nested_args):
    170         nested_args = (nested_args,)
--> 171       ret = autograph.tf_convert(self._func, ag_ctx)(*nested_args)
    172       ret = variable_utils.convert_variables_to_tensors(ret)
    173       if _should_pack(ret):

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py in wrapper(*args, **kwargs)
    690       except Exception as e:  # pylint:disable=broad-except
    691         if hasattr(e, 'ag_error_metadata'):
--> 692           raise e.ag_error_metadata.to_exception(e)
    693         else:
    694           raise

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py in wrapper(*args, **kwargs)
    687       try:
    688         with conversion_ctx:
--> 689           return converted_call(f, args, kwargs, options=options)
    690       except Exception as e:  # pylint:disable=broad-except
    691         if hasattr(e, 'ag_error_metadata'):

~/anaconda3/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py in converted_call(f, args, kwargs, caller_fn_scope, options)
    437     try:
    438       if kwargs is not None:
--> 439         result = converted_f(*effective_args, **kwargs)
    440       else:
    441         result = converted_f(*effective_args)

/tmp/__autograph_generated_filecu6im70c.py in tf__preprocess(file_name)
     11                 x = ag__.converted_call(ag__.ld(tf).io.decode_jpeg, (ag__.ld(x),), None, fscope)
     12                 (nrows, ncols, _) = ag__.ld(x).shape
---> 13                 x = ag__.converted_call(ag__.ld(tf).image.resize, (ag__.ld(x), (ag__.ld(nrows) // 2, ag__.ld(ncols) // 2)), None, fscope)
     14                 x = ag__.converted_call(ag__.ld(tf).image.random_crop, (ag__.ld(x), (32, 32)), None, fscope)
     15                 try:

TypeError: in user code:

    File "/tmp/ipykernel_583425/4207213119.py", line 7, in preprocess  *
        x = tf.image.resize(x, (nrows//2, ncols//2))

    TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'
```
