async def _dump_variant(self, writer, elem, elem_type=None, params=None):
if isinstance(elem, VariantType) or elem_type.WRAPS_VALUE:<EOL><INDENT>await dump_uint(writer, elem.variant_elem_type.VARIANT_CODE, <NUM_LIT:1>)<EOL>await self.dump_field(<EOL>writer, getattr(elem, elem.variant_elem), elem.variant_elem_type<EOL>)<EOL><DEDENT>else:<EOL><INDENT>fdef = find_variant_fdef(elem_type, elem)<EOL>await dump_uint(writer, fdef[<NUM_LIT:1>].VARIANT_CODE, <NUM_LIT:1>)<EOL>await self.dump_field(writer, elem, fdef[<NUM_LIT:1>])<EOL><DEDENT>
Dumps variant type to the writer.
Supports both wrapped and raw variant.

:param writer:
:param elem:
:param elem_type:
:param params:
:return: