TypeError from GenerationMixin.generate() when stopping_criteria is None
Author: ccmaymay
Pull request: no

### System Info

transformers 4.23.1
Anaconda Python 3.9.13
Linux

### Who can help?

*(Sorry, I think I botched filling in the template)*

I get an error from GenerationMixin.generate() when passing `stopping_criteria=None` explicitly, even though the type is annotated as Optional:

```
Traceback (most recent call last):
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/cmay/sandle/backend-hf/serve-backend-hf.py", line 444, in post_completions
    return jsonify(make_api_completions(response_id, created, model_id, lm.complete(
  File "/home/cmay/sandle/backend-hf/serve-backend-hf.py", line 158, in complete
    for (i, raw_completion) in enumerate(self._complete(
  File "/home/cmay/sandle/backend-hf/serve-backend-hf.py", line 247, in _complete
    output_token_ids = cast(torch.Tensor, model.generate(
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_c
ontext
    return func(*args, **kwargs)
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/transformers/generation_utils.py", line 1379, in gen
erate
    stopping_criteria = self._get_stopping_criteria(
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/transformers/generation_utils.py", line 801, in _get
_stopping_criteria
    criteria = self._merge_criteria_processor_list(criteria, stopping_criteria)
  File "/home/cmay/anaconda3/envs/sandle/lib/python3.9/site-packages/transformers/generation_utils.py", line 809, in _mer
ge_criteria_processor_list
    if len(custom_list) == 0:
TypeError: object of type 'NoneType' has no len()
```

The error comes from `_get_stopping_criteria` calling `_merge_criteria_processor_list` with `custom_list=None`:

```python
    def _get_stopping_criteria(
        self, max_length: Optional[int], max_time: Optional[float], stopping_criteria: Optional[StoppingCriteriaList]
    ) -> StoppingCriteriaList:
        criteria = StoppingCriteriaList()
        if max_length is not None:
            criteria.append(MaxLengthCriteria(max_length=max_length))
        if max_time is not None:
            criteria.append(MaxTimeCriteria(max_time=max_time))
        criteria = self._merge_criteria_processor_list(criteria, stopping_criteria)
        return criteria

    def _merge_criteria_processor_list(
        self,
        default_list: Union[LogitsProcessorList, StoppingCriteriaList],
        custom_list: Union[LogitsProcessorList, StoppingCriteriaList],
    ) -> Union[LogitsProcessorList, StoppingCriteriaList]:
        ...
```

@patrickvonplaten 

### Information

- [ ] The official example scripts
- [x] My own modified scripts

### Tasks

- [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```python
    def _complete(self, text: str, tokenizer: PreTrainedTokenizer, model: PreTrainedModel,          
                  stop_strings: List[str]) -> List[RawCompletion]:                                
        input_token_ids = tokenizer(text, return_tensors='pt')['input_ids']
        output_token_ids = model.generate(                                       
            input_token_ids,                
            stopping_criteria=StoppingCriteriaList(                                                 
                SubstringMatchStoppingCriteria(stop_string, text, tokenizer)                        
                for stop_string in stop_strings                                                     
            ) if stop_strings else None,                                                                                      
        )
```

Incidentally, I wrote this expecting `None` to be a safe default (given the type annotation of `Optional[StoppingCriteriaList]`) and an empty `StoppingCriteriaList` to be more risky (I wasn't sure if StoppingCriteriaList was designed to handle empty lists).  I was a little surprised when the opposite was true~

### Expected behavior

`GenerationMixIn.generate()` should behave the same when `stopping_criteria` is `None` or an empty `StoppingCriteriaList` (the current default).

Comments:
cc @gante 

@ccmaymay Agreed with your assessment! I see you're working on a fix, so I'll move further discussion there :)