code: def process(fetched_file, file_name, args, remove=True):
      assert len(args.rename) <= len(args.outputs), (
          "too few outputs to rename",
          args.rename,
          "into",
          args.outputs,
      )
  
      fetched_file_is_dir = os.path.isdir(fetched_file)
      if fetched_file_is_dir and not args.untar_to:
          raise ResourceIsDirectoryError(
              "Resource may be directory only with untar_to option: "
              + fetched_file
          )
  
      # make all read only
      if fetched_file_is_dir:
          for root, _, files in os.walk(fetched_file):
              for filename in files:
                  make_readonly(os.path.join(root, filename))
      else:
          make_readonly(fetched_file)
  
      if args.copy_to:
          hardlink_or_copy(fetched_file, args.copy_to)
          if not args.outputs:
              args.outputs = [args.copy_to]
  
      if args.rename_to:
          args.rename.append(fetched_file)
          if not args.outputs:
              args.outputs = [args.rename_to]
  
      if args.copy_to_dir:
          hardlink_or_copy(
              fetched_file, os.path.join(args.copy_to_dir, file_name)
          )
  
      if args.untar_to:
          ensure_dir(args.untar_to)
          inputs = set(
              map(
                  os.path.normpath,
                  args.rename + args.outputs[len(args.rename) :],
              )
          )
          if fetched_file_is_dir:
              for member in inputs:
                  base, name = member.split("/", 1)
                  src = os.path.normpath(
                      os.path.join(fetched_file, name)
                  )
                  dst = os.path.normpath(
                      os.path.join(args.untar_to, member)
                  )
                  hardlink_or_copy(src, dst)
          else:
              # Extract only requested files
              try:
                  with tarfile.open(fetched_file, mode="r:*") as tar:
                      members = [
                          entry
                          for entry in tar
                          if os.path.normpath(
                              os.path.join(args.untar_to, entry.name)
                          )
                          in inputs
                      ]
                      tar.extractall(args.untar_to, members=members)
              except tarfile.ReadError as e:
                  logging.exception(e)
                  raise ResourceUnpackingError(
                      "File {} cannot be untared".format(fetched_file)
                  )
  
          # Forbid changes to the loaded resource data
          for root, _, files in os.walk(args.untar_to):
              for filename in files:
                  make_readonly(os.path.join(root, filename))
  
      for src, dst in zip(args.rename, args.outputs):
          if src == "RESOURCE":
              src = fetched_file
          if os.path.abspath(src) == os.path.abspath(fetched_file):
              logging.info("Copying %s to %s", src, dst)
              hardlink_or_copy(src, dst)
          else:
              logging.info("Renaming %s to %s", src, dst)
              if os.path.exists(dst):
                  raise ResourceUnpackingError(
                      "Target file already exists ({} -> {})".format(
                          src, dst
                      )
                  )
              if remove:
                  rename_or_copy_and_remove(src, dst)
              else:
                  hardlink_or_copy(src, dst)
  
      for path in args.outputs:
          if not os.path.exists(path):
              raise OutputNotExistError(
                  "Output does not exist: %s" % os.path.abspath(path)
              )
          if not os.path.isfile(path):
              raise OutputIsDirectoryError(
                  "Output must be a file, not a directory: %s"
                  % os.path.abspath(path)
              )
          if args.executable:
              chmod(path, os.stat(path).st_mode | 0o111)
          if os.path.abspath(path) == os.path.abspath(fetched_file):
              remove = False
  
      if remove:
          if fetched_file_is_dir:
              shutil.rmtree(fetched_file)
          else:
              os.remove(fetched_file)
  
imports: import datetime
  import errno
  import hashlib
  import json
  import logging
  import os
  import platform
  import random
  import shutil
  import socket
  import string
  import sys
  import tarfile
  import urllib2
  import retry
label_desc: Use image node_id 17 for calling a global function with example usage: process(fetched_file, file_name, args, remove) without return types