def _prepare_profile_cache_path(self) -> Optional[str]:
        """Prepare local profile cache for this target."""
        if self.use_dummy_profiling_results():
            _LOGGER.info("Escape loading profile cache when using dummy profiling")
            return None

        prefix = None
        if os.environ.get("CACHE_DIR", None):
            prefix = os.environ.get("CACHE_DIR", None)
        cache_file = self._get_cache_file_name()
        if prefix is None:
            prefix = os.path.join(pathlib.Path.home(), ".aitemplate")

        try:
            os.makedirs(prefix, exist_ok=True)
        except OSError as error:
            _LOGGER.info(f"Cannot mkdir at {prefix} due to issue {error}")
            prefix = os.path.join(tempfile.mkdtemp(prefix="aitemplate_"), ".aitemplate")
            os.makedirs(prefix, exist_ok=True)
            _LOGGER.info(f"mkdir at {prefix} instead")

        cache_path = os.path.join(prefix, cache_file)
        flush_flag = os.environ.get("FLUSH_PROFILE_CACHE", "0")
        if flush_flag != "0":
            os.remove(cache_path)
        return cache_path
Prepare local profile cache for this target.
python/aitemplate/backend/target.py