code: def get_basic_local_path(
      opts: argparse.Namespace,
      path: str,
      cache_loc: str = TMP_CACHE_LOC,
      force_delete: Optional[bool] = None,
      use_start_rank: bool = True,
      sync_ranks: bool = True,
      *args,
      **kwargs,
  ) -> str:
      """
      If File name is a URL, download to TMP_CACHE_LOC and then return the local path. Otherwise, don't do anything
      """
      if force_delete is None:
          # An alternative approach is to move this logic to the argument's default value in the function signature:
          #     def get_basic_local_path(..., force_delete = if_test_env(False, otherwise=True), ...):
          # But that won't always worker because pytest may set PYTEST_CURRENT_TEST env set loading this module.
          force_delete = if_test_env(False, otherwise=True)
  
      if (
          path.find("s3://") > -1
          or path.find("http://") > -1
          or path.find("https://") > -1
      ):
          url_path = copy.deepcopy(path)
          ckpt_name = path.split(os.sep)[-1]
          local_path = "{}/{}".format(cache_loc, ckpt_name)
          local_path = str(local_path).strip()
  
          if os.path.isfile(local_path) and force_delete:
              # If file exists, remove it and then download again
              # This is important because if we are downloading from bolt tasks, then checkpoint names are the same
              if use_start_rank:
                  # remove files from start rank only
                  if is_start_rank_node(opts):
                      os.remove(local_path)
                  else:
                      while not os.path.isfile(local_path):
                          time.sleep(if_test_env(0, otherwise=1))
                          continue
              else:
                  # All ranks in DDP can remove the files
                  os.remove(local_path)
  
          if not os.path.isfile(local_path):
              if not use_start_rank or is_start_rank_node(opts):
                  _download_file(url_path, local_path)
              else:
                  while os.path.isfile(local_path):
                      # download file on start rank and let other ranks keep waiting till file is downloaded
                      # in DDP, download file in all ranks
                      time.sleep(if_test_env(0, otherwise=1))
                      continue
  
          if getattr(opts, "ddp.use_distributed", False) and sync_ranks:
              # synchronize between processes
              dist_barrier()
          return local_path
      return os.path.expanduser(path)
  
file_path: ml-cvnets/utils/download_utils_base.py
imports: import argparse
  import copy
  import os
  import time
  from typing import Optional
  import requests
  from common import TMP_CACHE_LOC, if_test_env
  from utils import logger
  from utils.ddp_utils import dist_barrier, is_start_rank_node
label_desc: Use image node_id 1 for calling a global function with example usage: get_basic_local_path(opts, path, cache_loc, force_delete, use_start_rank, sync_ranks) and returns: os, local_path