async def load_variant(self, elem_type, params=None, elem=None, wrapped=None):
is_wrapped = (isinstance(elem, x.VariantType) or elem_type.WRAPS_VALUE) if wrapped is None else wrapped<EOL>if is_wrapped:<EOL><INDENT>elem = elem_type() if elem is None else elem<EOL><DEDENT>tag = await load_uvarint(self.iobj)<EOL>for field in elem_type.f_specs():<EOL><INDENT>ftype = field[<NUM_LIT:1>]<EOL>vcode = ftype.BOOST_VARIANT_CODE if hasattr(ftype, '<STR_LIT>') else ftype.VARIANT_CODE<EOL>if vcode != tag:<EOL><INDENT>continue<EOL><DEDENT>fvalue = await self._load_field(ftype, field[<NUM_LIT:2>:], elem if not is_wrapped else None)<EOL>if is_wrapped:<EOL><INDENT>elem.set_variant(field[<NUM_LIT:0>], fvalue)<EOL><DEDENT>return elem if is_wrapped else fvalue<EOL><DEDENT>raise ValueError('<STR_LIT>' % (tag, self.tracker))<EOL>
Loads variant type from the reader.
Supports both wrapped and raw variant.

:param reader:
:param elem_type:
:param params:
:param elem:
:param wrapped:
:return: