code: def render_pep440_branch(pieces):
      """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
  
      The ".dev0" means not master branch. Note that .dev0 sorts backwards
      (a feature branch will appear "older" than the master branch).
  
      Exceptions:
      1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
      """
      if pieces["closest-tag"]:
          rendered = pieces["closest-tag"]
          if pieces["distance"] or pieces["dirty"]:
              if pieces["branch"] != "master":
                  rendered += ".dev0"
              rendered += plus_or_dot(pieces)
              rendered += "%d.g%s" % (
                  pieces["distance"],
                  pieces["short"],
              )
              if pieces["dirty"]:
                  rendered += ".dirty"
      else:
          # exception #1
          rendered = "0"
          if pieces["branch"] != "master":
              rendered += ".dev0"
          rendered += "+untagged.%d.g%s" % (
              pieces["distance"],
              pieces["short"],
          )
          if pieces["dirty"]:
              rendered += ".dirty"
      return rendered
  
imports: import errno
  import functools
  import os
  import re
  import subprocess
  import sys
  from typing import Callable, Dict
label_desc: Use image node_id 11 for calling a global function with example usage: render_pep440_branch(pieces) and returns: rendered