```python:inference/core/managers/base.py
from inference.core.env import USE_INFERENCE_MODELS
from inference.core.logger import logger

# Cache torch module at import time if needed
_torch = None
if USE_INFERENCE_MODELS:
    try:
        import torch
        _torch = torch
    except ImportError:
        pass

def try_releasing_cuda_memory() -> None:
    if not USE_INFERENCE_MODELS or _torch is None:
        # For now, we only want to have purge CUDA memory when USE_INFERENCE_MODELS is True
        # For now, we only want to have purge CUDA memory when USE_INFERENCE_MODELS is True
        return None
    try:
        if _torch.cuda.is_available():
            _torch.cuda.empty_cache()
    except Exception as error:
        logger.warning(f"Attempted to purge CUDA memory but failed with error: {error}")
```