version.parse(string) throws an error while comparing versions
Author: riteshghorse
Pull request: no

### System Info

In the [activations.py](https://github.com/huggingface/transformers/blob/977b2f05d5697f33e51111e4834a127a9a76349f/src/transformers/activations.py#L161), it uses version.parse to compare the torch version which can lead to subtle error as mentioned below.

When using `version.parse(str)`, it returns a `Version` object which is then sent to regex matching [here](https://github.com/pypa/packaging/blob/7e68d828f265ef05cf4cd3b5def9baffef8c2968/src/packaging/version.py#L198). This throws an error stating  
```
match = self._regex.search(version)
TypeError: expected string or bytes-like object
```

This was discovered when importing the latest pipeline of text to audio pipeline
```
File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/pipelines/__init__.py", line 73, in <module>
    from .text_to_audio import TextToAudioPipeline
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/pipelines/text_to_audio.py", line 22, in <module>
    from ..models.speecht5.modeling_speecht5 import SpeechT5HifiGan
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/models/speecht5/modeling_speecht5.py", line 27, in <module>
    from ...activations import ACT2FN
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/activations.py", line 250, in <module>
    mish = get_activation("mish")
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/activations.py", line 238, in get_activation
    return ACT2FN[activation_string]
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/activations.py", line 210, in __getitem__
    return cls(**kwargs)
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/activations.py", line 161, in __init__
    if version.parse(torch.__version__) < version.parse("1.9.0"):
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/packaging/version.py", line 52, in parse
    return Version(version)
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/packaging/version.py", line 196, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object
```


### Who can help?

@narsil

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```
from packaging import version

version.parse(torch.__version__)
```



### Expected behavior

instead we should do 

```
from packaging.version import Version

Version(torch.__version__)
```

Comments:
Hey! Thanks for reporting. Could you share a reproducer as well? 
```python 
from transformers import TextToAudioPipeline
```
does not throw an error so curious as how you got this? 

I got it in our PyDocs Precommit check
```
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/sphinx/ext/autodoc/importer.py", line 154, in import_module
    __import__(modname)
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/apache_beam/ml/inference/huggingface_inference.py", line 39, in <module>
    from transformers import Pipeline
  File "<frozen importlib._bootstrap>", line 1039, in _handle_fromlist
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1120, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/jenkins/jenkins-slave/workspace/beam_PreCommit_PythonDocs_Phrase/src/sdks/python/test-suites/tox/pycommon/build/srcs/sdks/python/target/.tox-py38-docs/py38-docs/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1132, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
expected string or bytes-like object
```

Full link here: https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Phrase/108/consoleText

actually `version.parse` will work just as fine but won't solve the issue here

The problem was on our end. We were mocking the torch import in autodoc which led to `torch.__version__` interpreted as None and threw the error `RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
expected string or bytes-like object`