<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dump(module, stream, cls=PVLEncoder, **kwargs):
 """Serialize ``module`` as a pvl module to the provided ``stream``. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param stream: a ``.write()``-supporting file-like object to serialize the module to. If ``stream`` is a string it will be treated as a filename :param cls: the encoder class used to serialize the pvl module. You may use the default ``PVLEncoder`` class or provided encoder formats such as the ```IsisCubeLabelEncoder``` and ```PDSLabelEncoder``` classes. You may also provided a custom sublcass of ```PVLEncoder``` :param **kwargs: the keyword arguments to pass to the encoder class. """

    if isinstance(stream, six.string_types):
        with open(stream, 'wb') as fp:
            return cls(**kwargs).encode(module, fp)
    cls(**kwargs).encode(module, stream)