There are plenty of examples and utility functions for downloading and opening models in the utils for the torch model hub 143. The key likely is to download them as an octet stream into bytes. You are probably best off using the api rather than reinventing the implementation.
Best regards
Thomas