code: def resolve_cache_dir(env_variable="MMF_CACHE_DIR", default="mmf"):
      # Some of this follow what "transformers" does for there cache resolving
      try:
          from torch.hub import _get_torch_home
  
          torch_cache_home = _get_torch_home()
      except ImportError:
          torch_cache_home = os.path.expanduser(
              os.getenv(
                  "TORCH_HOME",
                  os.path.join(
                      os.getenv("XDG_CACHE_HOME", "~/.cache"), "torch"
                  ),
              )
          )
      default_cache_path = os.path.join(torch_cache_home, default)
  
      cache_path = os.getenv(env_variable, default_cache_path)
  
      if not PathManager.exists(cache_path):
          try:
              PathManager.mkdirs(cache_path)
          except PermissionError:
              cache_path = os.path.join(get_mmf_root(), ".mmf_cache")
              PathManager.mkdirs(cache_path)
  
      return cache_path
  
imports: import collections
  import json
  import logging
  import os
  import warnings
  from ast import literal_eval
  from typing import List
  import torch
  from mmf.common.registry import registry
  from mmf.utils.env import import_user_module
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_absolute_path, get_mmf_root
  from omegaconf import DictConfig, errors, OmegaConf
label_desc: Use image node_id 11 for calling a global function with example usage: resolve_cache_dir(env_variable, default) and returns: cache_path