code: def _cmpkey(
      epoch: int,
      release: Tuple[int, ...],
      pre: Optional[Tuple[str, int]],
      post: Optional[Tuple[str, int]],
      dev: Optional[Tuple[str, int]],
      local: Optional[Tuple[SubLocalType]],
  ) -> CmpKey:
      # When we compare a release version, we want to compare it with all of the
      # trailing zeros removed. So we'll use a reverse the list, drop all the now
      # leading zeros until we come to something non zero, then take the rest
      # re-reverse it back into the correct order and make it a tuple and use
      # that for our sorting key.
      _release = tuple(
          reversed(
              list(
                  itertools.dropwhile(
                      lambda x: x == 0, reversed(release)
                  )
              )
          )
      )
  
      # We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
      # We'll do this by abusing the pre segment, but we _only_ want to do this
      # if there is not a pre or a post segment. If we have one of those then
      # the normal sorting rules will handle this case correctly.
      if pre is None and post is None and dev is not None:
          _pre: PrePostDevType = NegativeInfinity
      # Versions without a pre-release (except as noted above) should sort after
      # those with one.
      elif pre is None:
          _pre = Infinity
      else:
          _pre = pre
  
      # Versions without a post segment should sort before those with one.
      if post is None:
          _post: PrePostDevType = NegativeInfinity
  
      else:
          _post = post
  
      # Versions without a development segment should sort after those with one.
      if dev is None:
          _dev: PrePostDevType = Infinity
  
      else:
          _dev = dev
  
      if local is None:
          # Versions without a local segment should sort before those with one.
          _local: LocalType = NegativeInfinity
      else:
          # Versions with a local segment need that segment parsed to implement
          # the sorting rules in PEP440.
          # - Alpha numeric segments sort before numeric segments
          # - Alpha numeric segments sort lexicographically
          # - Numeric segments sort numerically
          # - Shorter versions sort before longer versions when the prefixes
          #   match exactly
          _local = tuple(
              (i, "") if isinstance(i, int) else (NegativeInfinity, i)
              for i in local
          )
  
      return epoch, _release, _pre, _post, _dev, _local
  
imports: import collections
  import itertools
  import re
  import warnings
  from typing import Callable, Iterator, List, Optional, SupportsInt, Tuple, Union
  from ._structures import Infinity, InfinityType, NegativeInfinity, NegativeInfinityType
label_desc: Use image node_id 6 for calling a global function with example usage: _cmpkey(epoch, release, pre, post, dev, local) and returns: epoch,  _release,  _pre,  _post,  _dev,  _local