TF: sample generation compatible with XLA and dynamic batch sizes
# What does this PR do?

Fixes #19747 (sample generation failing with XLA and dynamic batch sizes)

There were two distinct problems:
- `_expand_inputs_for_generation` was crashing when the input was a `TensorSpec` with dynamic batch size (used e.g. with tf.Serving). Fix: `tensor.shape` -> `tf.shape`
- Obtaining a new seed with `tf.random.Generator` is broken with `tf.function` for two distinct reasons: 1) the protection we added [here](https://github.com/huggingface/transformers/pull/18044/files) makes unseeded `sample` crash unless we call `sample` with eager execution first (see [here](https://www.tensorflow.org/api_docs/python/tf/random/set_global_generator) why); 2) TF 2.10 + XLA crashes on the line that instantiates it. Fix: replace TF-suggested method to generate seed with `tf.random.Generator` with `tf.experimental.numpy.random.randint`, since we were creating a Generator from a non-deterministic state anyways 🤷 Notes: the new `tf.experimental.numpy.random.randint` strategy seems to be slightly faster (23.5 ms -> 21.6 ms per generate call on a benchmark with XLA, nvidia 3090,  and `t5-small`) and is retrocompatible up to TF 2.4.0.
_The documentation is not available anymore as the PR was closed or merged._