code: def _SignedVarintDecoder(bits, result_type):
      """Like _VarintDecoder() but decodes signed values."""
  
      signbit = 1 << (bits - 1)
      mask = (1 << bits) - 1
  
      def DecodeVarint(buffer, pos):
          result = 0
          shift = 0
          while 1:
              b = six.indexbytes(buffer, pos)
              result |= (b & 0x7F) << shift
              pos += 1
              if not (b & 0x80):
                  result &= mask
                  result = (result ^ signbit) - signbit
                  result = result_type(result)
                  return (result, pos)
              shift += 7
              if shift >= 64:
                  raise _DecodeError(
                      "Too many bytes when decoding varint."
                  )
  
      return DecodeVarint
  
imports: import struct
  import six
  from google.protobuf.internal import encoder
  from google.protobuf.internal import wire_format
  from google.protobuf import message
label_desc: Use image node_id 2 for calling a global function with example usage: _SignedVarintDecoder(bits, result_type) and returns: DecodeVarint, result,  pos