code: async def _dump_variant(self, writer, elem, elem_type=None, params=None):
          
          if isinstance(elem, VariantType) or elem_type.WRAPS_VALUE:
              await dump_uint(writer, elem.variant_elem_type.VARIANT_CODE, 1)
              await self.dump_field(
                  writer, getattr(elem, elem.variant_elem), elem.variant_elem_type
              )
  
          else:
              fdef = find_variant_fdef(elem_type, elem)
              await dump_uint(writer, fdef[1].VARIANT_CODE, 1)
              await self.dump_field(writer, 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: