code: def infer_versioning_metadata(user_script):
      """
      Infer information about user's script versioning if available.
      Fills the following information in VCS:
  
      `is_dirty` shows whether the git repo is at a clean state.
      `HEAD_sha` gives the hash of head of the repo.
      `active_branch` shows the active branch of the repo.
      `diff_sha` shows the hash of the diff in the repo.
  
      :returns: the `VCS` but filled with above info.
  
      """
      git_repo = fetch_user_repo(user_script)
      if not git_repo:
          return {}
      if not git_repo.head.is_valid():
          logging.warning(
              f"Repository at {git_repo.git.rev_parse('--show-toplevel')} has an invalid HEAD. "
              "No commits maybe?"
          )
          return {}
  
      vcs = {}
      vcs["type"] = "git"
      vcs["is_dirty"] = git_repo.is_dirty()
      vcs["HEAD_sha"] = git_repo.head.object.hexsha
      if git_repo.head.is_detached:
          vcs["active_branch"] = None
      else:
          vcs["active_branch"] = git_repo.active_branch.name
      # The 'diff' of the current version from the latest commit
      diff = git_repo.git.diff(git_repo.head.commit.tree).encode(
          "utf-8"
      )
      diff_sha = hashlib.sha256(diff).hexdigest()
      vcs["diff_sha"] = diff_sha
      return vcs
  
imports: import copy
  import getpass
  import hashlib
  import logging
  import os
  import git
  import yaml
  from numpy import inf
  import orion
  import orion.core
  from orion.core.io.orion_cmdline_parser import OrionCmdlineParser
  from orion.core.utils.flatten import unflatten
label_desc: Use image node_id 10 for calling a global function with example usage: infer_versioning_metadata(user_script) and returns: vcs, dict, dict