async def dump_variant(self, elem, elem_type=None, params=None, obj=None):
fvalue = None<EOL>if isinstance(elem, x.VariantType) or elem_type.WRAPS_VALUE:<EOL><INDENT>try:<EOL><INDENT>self.tracker.push_variant(elem.variant_elem_type)<EOL>fvalue = {<EOL>elem.variant_elem: await self._dump_field(getattr(elem, elem.variant_elem), elem.variant_elem_type, obj=obj)<EOL>}<EOL>self.tracker.pop()<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise helpers.ArchiveException(e, tracker=self.tracker) from e<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>fdef = elem_type.find_fdef(elem_type.f_specs(), elem)<EOL>self.tracker.push_variant(fdef[<NUM_LIT:1>])<EOL>fvalue = {<EOL>fdef[<NUM_LIT:0>]: await self._dump_field(elem, fdef[<NUM_LIT:1>], obj=obj)<EOL>}<EOL>self.tracker.pop()<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise helpers.ArchiveException(e, tracker=self.tracker) from e<EOL><DEDENT><DEDENT>return fvalue<EOL>
Dumps variant type to the writer.
Supports both wrapped and raw variant.

:param elem:
:param elem_type:
:param params:
:param obj:
:return: