Use torch.unique_consecutive to check elements are same
# What does this PR do?

We use `torch.unique` here only to check whether every elements have the same value.
Therefore, we can use [`torch.unique_consecutive`](https://pytorch.org/docs/stable/generated/torch.unique_consecutive.html) here.

This function eliminates all but the first element from every consecutive group of equivalent elements.
Like, if we apply this function to `[1, 2, 2, 1]`, it will result in `[1, 2, 1]`.

As you could see, this is enough for checking whether every elements have the same value.

Since `torch.unique_consecutive` do less thing, it is much more faster.
On my computer, it is 25x faster on GPU and 15x faster on CPU.


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/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.

@patrickvonplaten