error message of tf.constant_initializer is not accuracy
Hi @cheyennee ,

Tensorflow deals Python numbers or numpy arrays as Tensors and converts them into Tensors wherever needed. Hence all the exception description contains Tensor reference only.Also within the API there are calls to several other APIs and hence the error description might not specifically mentioning the API specific argument because while passing arguments from one API to other the names of arguments also may be differed.This may not be true for all cases but for some.

In this case the argument `arg_input` internally converted to Tensor and then shape.ndims called upon this Tensor which is returning a scalar value '1' and there is no function `len()` for the scalar values.This is the source of error here.

Sometimes due to various other internal calls the error description might not have mention of specific API attributes. However the description is not so difficult for the users with minimum understanding of tensorflow. If you still feel that this description can be changable please feel free to raise a PR. @SuryanarayanaY Got that. Thanks for the detailed explanation. 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/60449">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/60449">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

tf 2.12.0

### Custom Code

Yes

### OS Platform and Distribution

win11

### 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 Behaviour?

When run below snippet code, it will throw an exception. It's correct to throw an exception, but I think the error message is not so accurate. The following error message is more for developers to see than to tell the user where the input parameter is wrong.

### Standalone code to reproduce the issue

```shell
import tensorflow as tf
results={}
try:
  value_0_tensor = tf.random.uniform([], dtype=tf.float32)
  value_0 = tf.identity(value_0_tensor)
  value = [value_0]
  arg_class = tf.constant_initializer(value=value,)
  arg_input_0 = 3
  arg_input_1 = 1
  arg_input = [arg_input_0,arg_input_1,]
  results["res"] = arg_class(*arg_input)
except Exception as e:
  results["err"] = "Error:"+str(e)
print(results)
# results={'err': 'Error:TypeError: Scalar tensor has no `len()`\nTraceback (most recent call last):\n\n  File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ops.py", line 1107, in __len__\n    raise TypeError("Scalar tensor has no `len()`")\n\nTypeError: Scalar tensor has no `len()`\n\n'}
```
```


### Relevant log output

_No response_</details>