code: def _nightly_version(spdir: str) -> str:
      # first get the git version from the installed module
      version_fname = os.path.join(spdir, "torch", "version.py")
      with open(version_fname) as f:
          lines = f.read().splitlines()
      for line in lines:
          if not line.startswith("git_version"):
              continue
          git_version = literal_eval(line.partition("=")[2].strip())
          break
      else:
          raise RuntimeError(
              f"Could not find git_version in {version_fname}"
          )
      print(f"Found released git version {git_version}")
      # now cross reference with nightly version
      _ensure_commit(git_version)
      cmd = ["git", "show", "--no-patch", "--format=%s", git_version]
      p = subprocess.run(
          cmd,
          capture_output=True,
          check=True,
          text=True,
      )
      m = SHA1_RE.search(p.stdout)
      if m is None:
          raise RuntimeError(
              f"Could not find nightly release in git history:\n  {p.stdout}"
          )
      nightly_version = m.group(1)
      print(f"Found nightly release version {nightly_version}")
      # now checkout nightly version
      _ensure_commit(nightly_version)
      return nightly_version
  
imports: import contextlib
  import datetime
  import functools
  import glob
  import json
  import logging
  import os
  import re
  import shutil
  import subprocess
  import sys
  import tempfile
  import time
  import uuid
  from argparse import ArgumentParser
  from ast import literal_eval
  from typing import Any, Callable, cast, Dict, Generator, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, TypeVar
label_desc: Use image node_id 17 for calling a global function with example usage: _nightly_version(spdir) and returns: nightly_version