<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collect_environment(no_cache: bool = False) -> dict: """ Return the version of the Python executable, the versions of the currently loaded packages \ and the running platform. The result is cached unless `no_cache` is True. """

    global _env
    if _env is None or no_cache:
        _env = collect_environment_without_packages()
        _env["packages"] = collect_loaded_packages()
    return _env