code: def render_pep440(pieces: Dict[str, Any]) -> str:
      """Build up version string, with post-release "local version identifier".
  
      Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
      get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
  
      Exceptions:
      1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
      """
      if pieces["closest-tag"]:
          rendered = pieces["closest-tag"]
          if pieces["distance"] or pieces["dirty"]:
              rendered += plus_or_dot(pieces)
              rendered += "%d.g%s" % (
                  pieces["distance"],
                  pieces["short"],
              )
              if pieces["dirty"]:
                  rendered += ".dirty"
      else:
          # exception #1
          rendered = "0+untagged.%d.g%s" % (
              pieces["distance"],
              pieces["short"],
          )
          if pieces["dirty"]:
              rendered += ".dirty"
      return rendered
  
imports: import configparser
  import errno
  import json
  import os
  import re
  import subprocess
  import sys
  from pathlib import Path
  from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Union
  from typing import NoReturn
  import functools
label_desc: Use image node_id 13 for calling a global function with example usage: render_pep440(pieces) and returns: rendered