code: def copy_file(input_file, destination_dir, tmp_destination_dir):
      """
      Copy a given input_file from source to the destination directory.
  
      Steps:
      1. We use g_pathmgr to extract the data to local path.
      2. we simply move the files from the g_pathmgr cached local directory
         to the user specified destination directory. We use rsync.
         How destination dir is chosen:
              a) If user is using slurm, we set destination_dir = slurm_dir (see get_slurm_dir)
              b) If the local path used by PathManafer is same as the input_file path,
                 and the destination directory is not specified, we set
                 destination_dir = tmp_destination_dir
  
      Returns:
          output_file (str): the new path of the file
          destination_dir (str): the destination dir that was actually used
      """
      # we first extract the local path for the files. g_pathmgr
      # determines the local path itself and copies data there.
      logging.info(f"Copying {input_file} to local path...")
      out = g_pathmgr.get_local_path(input_file)
      output_dir = os.path.dirname(out)
      logging.info(f"File coped to: {out}")
  
      if (out == input_file) and not destination_dir:
          destination_dir = tmp_destination_dir
          logging.info(
              f"The file wasn't copied. Copying again to temp "
              f"destination directory: {destination_dir}"
          )
      # if the user wants to copy the files to a specific location,
      # we simply move the files from the g_pathmgr cached directory
      # to the user specified directory.
      destination_dir = get_slurm_dir(destination_dir)
      if "SLURM_JOBID" in os.environ:
          destination_dir = get_slurm_dir(destination_dir)
      if destination_dir is not None:
          makedir(destination_dir)
          output_file = (
              f"{destination_dir}/{os.path.basename(input_file)}"
          )
          if g_pathmgr.exists(output_file):
              logging.info(f"File already copied: {output_file}")
              return output_file, destination_dir
  
          logging.info(
              f"Copying file: {input_file} to destination: {destination_dir}"
          )
          stime = time.perf_counter()
          os.system(f"rsync -a --progress {out} {destination_dir}")
          etime = time.perf_counter()
          logging.info(
              f"Copied file | time (sec): {round(etime - stime, 4)} "
              f"size: {get_file_size(output_file)}"
          )
          return output_file, destination_dir
      else:
          return out, output_dir
  
imports: import json
  import logging
  import os
  import pickle
  import re
  import shutil
  import time
  from urllib.parse import urlparse
  import numpy
  import pandas
  import yaml
  from iopath.common.download import download
  from iopath.common.file_io import file_lock, g_pathmgr
  from vissl.utils.slurm import get_slurm_dir
label_desc: Use image node_id 10 for calling a global function with example usage: copy_file(input_file, destination_dir, tmp_destination_dir) and returns: output_file,  destination_dir, out,  output_dir, output_file,  destination_dir