code: def checkout_commit(repo, commit_id):
      """
      Context manager that checks out a commit in the repo.
      """
      current_head = (
          repo.head.commit if repo.head.is_detached else repo.head.ref
      )
  
      try:
          repo.git.checkout(commit_id)
          yield
  
      finally:
          repo.git.checkout(current_head)
  
imports: import argparse
  import collections
  import json
  import os
  import re
  from contextlib import contextmanager
  from pathlib import Path
  from git import Repo
label_desc: Use image node_id 1 for calling a global function with example usage: checkout_commit(repo, commit_id) without return types