code: async def dump_variant(self, elem, elem_type=None, params=None):
          
          if isinstance(elem, x.VariantType) or elem_type.WRAPS_VALUE:
              await dump_uvarint(self.iobj, elem.variant_elem_type.VARIANT_CODE)
              await self._dump_field(getattr(elem, elem.variant_elem), elem.variant_elem_type)
  
          else:
              fdef = elem_type.find_fdef(elem_type.f_specs(), elem)
              vcode = fdef[1].BOOST_VARIANT_CODE if hasattr(fdef[1], 'BOOST_VARIANT_CODE') else fdef[1].VARIANT_CODE
              await dump_uvarint(self.iobj, vcode)
              await self._dump_field(elem, fdef[1])
docs: Dumps variant type to the writer.
          Supports both wrapped and raw variant.
  
          :param writer:
          :param elem:
          :param elem_type:
          :param params:
          :return: