class_docstr: Takes a snapshot of the git repository that the script lives in.
  
  This ensures that remote jobs always use the code from when they are scheduled
  and not the code from when they are launched / re-started.
  
  
  Parameters
  ----------
  snapshot_dir: Path
      A path to where the snapshot should be created
  with_submodules: bool
      Whether or not submodules should be included in the snapshot
  exclude: Sequence[str]
      An optional list of patterns to exclude from the snapshot
  include: Sequence[str]
      A list of relative file names to include from the snapshot.
      Useful for .so or other build artifacts that are genarally not tracked by git.
  
  Note
  ----
  - Only files that are checked in to the repository are included in the snapshot.
      If you have experimental code that you would like to include in the snapshot,
      you'll need to `git add` the file first for it to be included, or use `include` arg.
code: def __exit__(self, *args):
      os.chdir(self.original_dir)
  
imports: import collections
  import contextlib
  import datetime
  import itertools
  import os
  import random
  import shutil
  import subprocess
  import tempfile
  import time
  import typing
  from pathlib import Path
  from .core import core
  from .core.job_environment import JobEnvironment
  from .core.utils import CommandFunction
  from .core.utils import DelayedSubmission
  from .core.utils import environment_variables
label_desc: Use image node_id 4 for calling the RsyncSnapshot obj's underlying member method code with example usage: obj.__exit__() without return types