use __func__ to check can_generate
Author: xin3he
Pull request: yes

# What does this PR do?

Fixes # (the issue description is as follows)
When using `model.generate()` it calls `self._validate_model_class()` to check if model can do generate.
If we use `str(self.prepare_inputs_for_generation)` it will dump the entire model architecture which consumes resource and is not necessary.
Using `str(self.prepare_inputs_for_generation.__func__)` is a better equivalent replacement.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer: @stas00, Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._

Could you share a script that shows any improvement? The model is a reference type, so what will be shared is a pointer to that class.

cc @gante 

```
import transformers
import time

model_name = 'facebook/bart-large-cnn'
model = transformers.AutoModelForSeq2SeqLM.from_pretrained(model_name)

start = time.time()
#print(model.can_generate())
print(model._validate_model_class())
print('time1:', time.time() - start)

start = time.time()
if "GenerationMixin" in str(model.prepare_inputs_for_generation.__func__):
    pass
print('time2:', time.time() - start)

start = time.time()
if "GenerationMixin" in str(model.prepare_inputs_for_generation):
    pass
print('time3:', time.time() - start)


"""
Result from my side:
True
time1: 0.001619100570678711
time2: 5.245208740234375e-06
time3: 0.0012629032135009766
"""


from optimum.intel.neural_compressor.quantization import IncQuantizedModelForSeq2SeqLM
model_name = 'Intel/bart-large-cnn-int8-dynamic'
model = IncQuantizedModelForSeq2SeqLM.from_pretrained(model_name)

start = time.time()
print(model._validate_model_class())
print('time1:', time.time() - start)

start = time.time()
if "GenerationMixin" in str(model.prepare_inputs_for_generation.__func__):
    pass
print('time2:', time.time() - start)

start = time.time()
if "GenerationMixin" in str(model.prepare_inputs_for_generation):
    pass
print('time3:', time.time() - start)


"""
Result from my side:
True
time1: 0.5971765518188477
time2: 7.3909759521484375e-06
time3: 0.5961868762969971
"""
```