code: def _tar_path(
      source_path: str, target_file: str, compression: bool = False
  ) -> _TarResults:
      """Create tar from directory using `tar`
  
      Parameters
      ----------
      source_path: str
          Source directory or file
      target_file
          Target tar file
      compression: bool, default False
          Enable compression, which is disabled by default.
  
      Returns
      -------
      TarResults
          Results that holds file counts and sizes
  
      """
      if os.path.isdir(source_path):
          before_size, _ = _get_dir_size_and_count(source_path)
      else:
          before_size = os.path.getsize(source_path)
  
      try:
          _tar_path_subprocess(source_path, target_file, compression)
      except subprocess.CalledProcessError:
          _tar_path_python(source_path, target_file, compression)
  
      after_size = os.stat(target_file).st_size
      return _TarResults(before_size=before_size, after_size=after_size)
  
file_path: pytorch-lightning/src/lightning/app/source_code/tar.py
imports: import math
  import os
  import subprocess
  import tarfile
  from dataclasses import dataclass
  from typing import Optional, Tuple
  import click
label_desc: Use image node_id 3 for calling a global function with example usage: _tar_path(source_path, target_file, compression) and returns: _TarResults