def register_custom_type(<EOL>self, cls: type, marshaller: Optional[Callable[[Any], Any]] = default_marshaller,<EOL>unmarshaller: Union[Callable[[Any, Any], None],<EOL>Callable[[Any], Any], None] = default_unmarshaller, *,<EOL>typename: str = None, wrap_state: bool = True) -> None:
assert check_argument_types()<EOL>typename = typename or qualified_name(cls)<EOL>if marshaller:<EOL><INDENT>self.marshallers[cls] = typename, marshaller, wrap_state<EOL>self.custom_type_codec.register_object_encoder_hook(self)<EOL><DEDENT>if unmarshaller and self.custom_type_codec is not None:<EOL><INDENT>target_cls = cls  <EOL>if len(signature(unmarshaller).parameters) == <NUM_LIT:1>:<EOL><INDENT>target_cls = None<EOL><DEDENT>self.unmarshallers[typename] = target_cls, unmarshaller<EOL>self.custom_type_codec.register_object_decoder_hook(self)<EOL><DEDENT>
Register a marshaller and/or unmarshaller for the given class.

The state object returned by the marshaller and passed to the unmarshaller can be any
serializable type. Usually a dictionary mapping of attribute names to values is used.

.. warning:: Registering marshallers/unmarshallers for any custom type will override any
    serializer specific encoding/decoding hooks (respectively) already in place!

:param cls: the class to register
:param marshaller: a callable that takes the object to be marshalled as the argument and
      returns a state object
:param unmarshaller: a callable that either:

    * takes an uninitialized instance of ``cls`` and its state object as arguments and
      restores the state of the object
    * takes a state object and returns a new instance of ``cls``
:param typename: a unique identifier for the type (defaults to the ``module:varname``
    reference to the class)
:param wrap_state: ``True`` to wrap the marshalled state before serialization so that it
    can be recognized later for unmarshalling, ``False`` to serialize it as is