TFGenerationMixin.generate should support a parameter such as logit_mask
### Feature request

when i use encoder-decoder model for relation extract task,   I make sure the decoder output must in encoder input text.  so a parameter such logit_mask should be necessary.

### Motivation

when I use prompt finetuning a encoder-decoder to extract spo, I make sure the decoder output must in encoder input text. I try so many ways to Implement model constraint generation，but I filed，bad_world_ids parameter is not enough.

### Your contribution

I think TFGenerationMixin.generate should support a parameter such as logit_mask to mask next tokens score.
Hey @TheHonestBob 👋 If your task is not TensorFlow-dependent, would the constraints-related arguments in the more complete pytorch version help? ([docs here](https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.generation_utils.GenerationMixin))<|||||>> Hey @TheHonestBob 👋 If your task is not TensorFlow-dependent, would the constraints-related arguments in the more complete pytorch version help? ([docs here](https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.generation_utils.GenerationMixin))

thanks for your reply， I read this docs，in pytorch generation_utils.py logits_processor parameter maybe I want，but not in tensorflow-dependent，I always use tf to code. on the other hand，I found that in the TFPreTrainedModel's subclass call func always return TFSeq2SeqLMOutput class, it's very python nice, but TFPreTrainedModel don't Implement fit() func, there will be two problem in my opinion，1. if I inherit TFPreTrainedModel to Implement my model ，I can't use fit() func, because fit func require call() func return fixed format, 2. if I use tf.keras.model.Model to Implement my model, I can't use generate func, as well as inherit TFGenerationMixin also can't solve it.<|||||>`TFPreTrainedModel` is not meant to be a stand-alone model, but something your model inherits from :) See [here](https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_tf_t5.py#L1260) for an example. When built this way, `fit()` will work as usual with Keras, and the model will have `generate()` support. However, it is quite complex to build, as you might notice -- I'd recommend starting from an existing model.

As for the original logit masking feature, I'm going to tag @patil-suraj and @patrickvonplaten -- do we have some functionality related to this feature request? (see issue at the top)<|||||>We have `bad_token_word_ids` which should do exactly this:
https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.generation_utils.GenerationMixin.generate.bad_words_ids(List[List[int]],

Could you try this @TheHonestBob ?<|||||>> `TFPreTrainedModel` is not meant to be a stand-alone model, but something your model inherits from :) See [here](https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_tf_t5.py#L1260) for an example. When built this way, `fit()` will work as usual with Keras, and the model will have `generate()` support. However, it is quite complex to build, as you might notice -- I'd recommend starting from an existing model.
> 
> As for the original logit masking feature, I'm going to tag @patil-suraj and @patrickvonplaten -- do we have some functionality related to this feature request? (see issue at the top)
thanks for your reply，I view lastest Bart source code, in my opinion，transformers overwrite so many tensorflow func, such as train_step compile, I haven't done more experiments to verify whether the latest code is more compatible with tensorflow, I feel that the transformers library is too integrated, and seems to lack the flexibility of tensorflow. If I need more flexible requirements, I may have to write more code. The transformers library looks more and more like an AI framework based on tensorflow, rather than an easy-to-use pre training model library, because the transformers library has its own entire training and prediction logic, Maybe the above is just that I don't know much about the transformers library.
<|||||>> We have `bad_token_word_ids` which should do exactly this: [https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.generation_utils.GenerationMixin.generate.bad_words_ids(List[List[int]]](https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.generation_utils.GenerationMixin.generate.bad_words_ids(List%5BList%5Bint%5D%5D),
> 
> Could you try this @TheHonestBob ?

thanks for your reply, I try this, in my opinion，this parameter not python nice，if bad word more than 20000，or each batch data have different bad word，I think this parameter will work not well.<|||||>> `TFPreTrainedModel` is not meant to be a stand-alone model, but something your model inherits from :) See [here](https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_tf_t5.py#L1260) for an example. When built this way, `fit()` will work as usual with Keras, and the model will have `generate()` support. However, it is quite complex to build, as you might notice -- I'd recommend starting from an existing model.
> 
> As for the original logit masking feature, I'm going to tag @patil-suraj and @patrickvonplaten -- do we have some functionality related to this feature request? (see issue at the top)

thanks for your reply，I view lastest Bart source code, in my opinion，transformers overwrite so many tensorflow func, such as train_step compile, I haven't done more experiments to verify whether the latest code is more compatible with tensorflow, I feel that the transformers library is too integrated, and seems to lack the flexibility of tensorflow. If I need more flexible requirements, I may have to write more code. The transformers library looks more and more like an AI framework based on tensorflow, rather than an easy-to-use pre training model library, because the transformers library has its own entire training and prediction logic, Maybe the above is just that I don't know much about the transformers library.<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.