[docs]defget_path(clb:Callable[...,Any])->str:"""Returns the path to the input callable. Args: clb: The callable to retrieve the path for. Returns: The full module path to :paramref:`clb`. """returnf"{clb.__module__}.{clb.__name__}"
[docs]defseed_all(seed:int|np.uint32)->None:"""Sets the random seed for all relevant libraries. Args: seed: The random seed. """random.seed(a=int(seed))np.random.seed(seed=seed)torch.manual_seed(seed=seed)torch.cuda.manual_seed(seed=int(seed))torch.cuda.manual_seed_all(seed=int(seed))
[docs]defcan_connect_to_internet()->bool:"""Checks whether an internet connection is available."""try:response=requests.get(url="https://www.google.com",timeout=5)response.raise_for_status()exceptException:# noqa: BLE001returnFalsereturnTrue