make run_generation more generic for other devices
Author: ji-huazhong
Pull request: yes

## What does this PR do?
Currently, the example for text-generation is only available for cuda or cpu. This PR makes it work well on mps or npu devices.

Verified on A100 and npu.

Example usage:
```
python3 run_generation.py \
    --model_type=gpt2 \
    --model_name_or_path=gpt2
```

Below are the output logs:
- On GPU
  ```
  07/27/2023 11:23:51 - WARNING - __main__ - device: cuda, n_gpu: 8, 16-bits training: False
  Using pad_token, but it is not set yet.
  07/27/2023 11:23:57 - INFO - __main__ - Namespace(model_type='gpt2', model_name_or_path='gpt2', prompt='', length=20, stop_token=None, temperature=1.0, repetition_penalty=1.0, k=0, p=0.9, prefix='', padding_text='', xlm_language='', seed=42, use_cpu=False, num_return_sequences=1, fp16=False, jit=False, device=device(type='cuda'), n_gpu=8)
  Model prompt >>> "I'm Jack
  The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
  Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation.
  === GENERATED SEQUENCE 1 ===
  "I'm Jack Russell."
  
  "They said, 'Hey, you know, you have to get away with
  ```

- On NPU：
  ```
  07/27/2023 11:21:47 - WARNING - __main__ - device: npu, n_gpu: 8, 16-bits training: False
  Using pad_token, but it is not set yet.
  07/27/2023 11:22:03 - INFO - __main__ - Namespace(device=device(type='npu'), fp16=False, jit=False, k=0, length=20, model_name_or_path='gpt2', model_type='gpt2', n_gpu=8, num_return_sequences=1, p=0.9, padding_text='', prefix='', prompt='', repetition_penalty=1.0, seed=42, stop_token=None, temperature=1.0, use_cpu=False, xlm_language='')
  Model prompt >>> "I'm Jack
  The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
  Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation.
  === GENERATED SEQUENCE 1 ===
  "I'm Jack Dylan," guitarist Tim Farrell said, picking up Dylan's Lave Club guitar and in a playful styl
  ```

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

@muellerzr Hey there! I've addressed some code quality check warnings. Could you take a look at this PR? Thank you!

> Thanks! There's some errors in here we need to fix, and we can probably also improve the mixed precision to use accelerate if we want to (though if not, that's okay!)

@muellerzr I have resolved these errors. Would you kindly spare a moment to review this PR again? Thank you.

> As @sgugger pointed out, we don't want to wrap the mixed precision here actually during inference and just want to make sure the device is working. As a result we should use a different and simpler API, the [PartialState](https://huggingface.co/docs/accelerate/package_reference/state#accelerate.PartialState), which is designed for such situations. I've added suggestions for each change as a result, and appreciate your patience making sure this all will be great!

Thanks for the suggestion to make it more reasonable. I refactored this PR with `PartialState`, would you mind taking a look again.

Very clean! Thansk!