docs: def encode_nibbles(nibbles):
      """
      The Hex Prefix function
      """
      if is_nibbles_terminated(nibbles):
          flag = HP_FLAG_2
      else:
          flag = HP_FLAG_0
  
      raw_nibbles = remove_nibbles_terminator(nibbles)
  
      is_odd = len(raw_nibbles) % 2
  
      if is_odd:
          flagged_nibbles = tuple(itertools.chain(
              (flag + 1,),
              raw_nibbles,
          ))
      else:
          flagged_nibbles = tuple(itertools.chain(
              (flag, 0),
              raw_nibbles,
          ))
  
      prefixed_value = nibbles_to_bytes(flagged_nibbles)
  
      return prefixed_value