Repository: Lightning-Universe/lightning-flash

Issue:
Not able to import flash as transformer.__spec__ is returning None
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
I am trying to complete a summarization project and decided to use flash for it but am getting import error as `transformers.__spec__`  is returning None. I have opened huggingface/transformers#12904  issue on transformers page meanwhile, would like to know if there's a possible workaround to it.

#### Code sample
<!-- Ideally attach a minimal code sample to reproduce the decried issue.
Minimal means having the shortest code but still preserving the bug. -->

```
import transformers
print(transformers.__version__)
print(transformers.__spec__)

import flash
```

**OUTPUT**:
```
4.8.2
None
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-d02f1c770adc> in <module>
      3 print(transformers.__spec__)
      4 
----> 5 import flash

/opt/conda/lib/python3.7/site-packages/flash/__init__.py in <module>
     16 
     17 from flash.__about__ import *  # noqa: F401 F403
---> 18 from flash.core.utilities.imports import _TORCH_AVAILABLE
     19 
     20 if _TORCH_AVAILABLE:

/opt/conda/lib/python3.7/site-packages/flash/core/utilities/imports.py in <module>
     75 _PYTORCHVIDEO_AVAILABLE = _module_available("pytorchvideo")
     76 _MATPLOTLIB_AVAILABLE = _module_available("matplotlib")
---> 77 _TRANSFORMERS_AVAILABLE = _module_available("transformers")
     78 _PYSTICHE_AVAILABLE = _module_available("pystiche")
     79 _FIFTYONE_AVAILABLE = _module_available("fiftyone")

/opt/conda/lib/python3.7/site-packages/flash/core/utilities/imports.py in _module_available(module_path)
     36     """
     37     try:
---> 38         return find_spec(module_path) is not None
     39     except AttributeError:
     40         # Python 3.6

/opt/conda/lib/python3.7/importlib/util.py in find_spec(name, package)
    112         else:
    113             if spec is None:
--> 114                 raise ValueError('{}.__spec__ is None'.format(name))
    115             return spec
    116 

ValueError: transformers.__spec__ is None
```

### Expected behavior

<!-- A clear and concise description of what you expected to happen. -->
Able to import flash

### Environment

 - PyTorch Version (e.g., 1.0):  3.7.0/3.8.1
 - OS (e.g., Linux):
 - Platform: Colab/Kaggle
 - How you installed PyTorch (`conda`, `pip`, source): 
 - Build command you used (if compiling from source):
 - Python version:
 - CUDA/cuDNN version:
 - GPU models and configuration:
 - Any other relevant information:

### Additional context

<!-- Add any other context about the problem here. -->



Discussion:

Resolving patch:
diff --git a/flash/core/utilities/imports.py b/flash/core/utilities/imports.py
--- a/flash/core/utilities/imports.py
+++ b/flash/core/utilities/imports.py
@@ -43,6 +43,9 @@ def _module_available(module_path: str) -> bool:
     except ModuleNotFoundError:
         # Python 3.7+
         return False
+    except ValueError:
+        # Sometimes __spec__ can be None and gives a ValueError
+        return True
 
 
 def _compare_version(package: str, op, version) -> bool:
@@ -59,7 +62,7 @@ def _compare_version(package: str, op, version) -> bool:
     try:
         pkg_version = Version(pkg.__version__)
     except TypeError:
-        # this is mock by sphinx, so it shall return True ro generate all summaries
+        # this is mock by sphinx, so it shall return True to generate all summaries
         return True
     return op(pkg_version, Version(version))
 


Test patch: