Better check for packages availability
Following up huggingface/accelerate#1356
Refactor checks to avoid boilerplate and to ensure we are not picking up a folder that happens to be called as the package.

I assume all _*_available are for caching purposes. But is that really needed?
_The documentation is not available anymore as the PR was closed or merged._<|||||>> Thanks a lot for the refactor, this is super nice!
> 
> There are a couple of packages that do not properly implement metadata (I kno for sure `opencv` does not since we are adding it in another PR), could you quickly check that all the packages for which you did this PR do implement the metadata? if they don't we need to rely on the old way, which is fine as it should be an exceptional case.

I have checked the packages and found issues only on sklearn (the import is sklearn and package scikit-learn) and decord.

Could you please double check: smdistributed, tensorflow_text, torchdistx?<|||||>I have validated that `tensorflow_text` works. Installing `torchdistx` seems to painful for the time I have right now, but looking at the GitHub, everything should be fine.

Checking internally for `smdistributed` since it only exists in SageMaker envirnoments.<|||||>Not hearing anything back on `smdistributed`, so let's just merge this PR and see if anyone complains :sweat_smile: 

Can you just fix the conflict?<|||||>don't think failures are due to this PR. Also main is failing