code: def ulid_to_binary(ulid):
      
      if isinstance(ulid, uuid.UUID):
          return ulid.bytes
      if isinstance(ulid, (text_type, bytes)) and len(ulid) == 26:
          return decode_ulid_base32(ulid)
      if isinstance(ulid, (bytes, bytearray)) and len(ulid) == 16:
          return ulid
      raise InvalidULID('can not convert ulid %r to binary' % ulid)
docs: Convert an ULID to its binary representation.
  
      :param ulid: An ULID (either as UUID, base32 ULID or binary)
      :return: Bytestring of length 16
      :rtype: bytes