code: def copy_all_python_files(
      source, snapshot_main_dir, code_snapshot_hash
  ):
      """
      Copies following files from source to destination:
          a) all *.py files at direct source location.
          b) all mmf/*.py recursively.
      """
      os.makedirs(snapshot_main_dir, exist_ok=True)
      destination = os.path.join(snapshot_main_dir, code_snapshot_hash)
      assert not os.path.exists(
          destination
      ), f"Code snapshot: {code_snapshot_hash} alredy exists"
      os.makedirs(destination)
      all_pys = (
          glob(os.path.join(source, "mmf/**/*.py"), recursive=True)
          + glob(os.path.join(source, "tools/**/*.py"), recursive=True)
          + glob(os.path.join(source, "*.py"))
      )
  
      for filepath in all_pys:
          directory, filename = os.path.split(filepath)
          if directory:
              os.makedirs(
                  os.path.join(destination, directory), exist_ok=True
              )
          shutil.copy2(
              os.path.join(source, filepath),
              os.path.join(destination, filepath),
          )
      return destination
  
file_path: mmf/tools/sweeps/lib/slurm.py
imports: import datetime
  import itertools
  import os
  import random
  import shlex
  import shutil
  import subprocess
  from collections import OrderedDict
  from glob import glob
  from mmf.utils.general import get_mmf_root
label_desc: Use image node_id 2 for calling a global function with example usage: copy_all_python_files(source, snapshot_main_dir, code_snapshot_hash) and returns: destination