def encode(self, base: Union[(None, str, Multibase)]=None) -> str:
    '\n            Encodes the CID using a given multibase. If :obj:`None` is given,\n            the CID\'s own multibase is used by default.\n\n            Example usage:\n\n            >>> s = "zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA"\n            >>> cid = CID.decode(s)\n            >>> cid.encode() # default: cid.base\n            \'zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA\'\n            >>> cid.encode("base32")\n            \'bafkreidon73zkcrwdb5iafqtijxildoonbwnpv7dyd6ef3qdgads2jc4su\'\n\n            :param base: the multibase to be used for encoding\n            :type base: :obj:`None`, :obj:`str` or :class:`~multiformats.multibase.Multibase`, *optional*\n\n            :raises KeyError: see :meth:`multiformats.multibase.Multibase.encode`\n\n        '
    if (self.version == 0):
        if (base is not None):
            raise ValueError('CIDv0 cannot be multibase-encoded, please set multibase=None.')
        return base58btc.encode(bytes(self))
    if ((base is None) or (base == self.base)):
        base = self.base
    elif isinstance(base, str):
        base = multibase.get(base)
    else:
        multibase.validate_multibase(base)
    return base.encode(bytes(self))
Encodes the CID using a given multibase. If :obj:`None` is given,
the CID's own multibase is used by default.

Example usage:

>>> s = "zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA"
>>> cid = CID.decode(s)
>>> cid.encode() # default: cid.base
'zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA'
>>> cid.encode("base32")
'bafkreidon73zkcrwdb5iafqtijxildoonbwnpv7dyd6ef3qdgads2jc4su'

:param base: the multibase to be used for encoding
:type base: :obj:`None`, :obj:`str` or :class:`~multiformats.multibase.Multibase`, *optional*

:raises KeyError: see :meth:`multiformats.multibase.Multibase.encode`
def encode(self, base: Union[(None, str, Multibase)]=None) -> str:
    '\n            Encodes the CID using a given multibase. If :obj:`None` is given,\n            the CID\'s own multibase is used by default.\n\n            Example usage:\n\n            >>> s = "zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA"\n            >>> cid = CID.decode(s)\n            >>> cid.encode() # default: cid.base\n            \'zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA\'\n            >>> cid.encode("base32")\n            \'bafkreidon73zkcrwdb5iafqtijxildoonbwnpv7dyd6ef3qdgads2jc4su\'\n\n            :param base: the multibase to be used for encoding\n            :type base: :obj:`None`, :obj:`str` or :class:`~multiformats.multibase.Multibase`, *optional*\n\n            :raises KeyError: see :meth:`multiformats.multibase.Multibase.encode`\n\n        '
    if (self.version == 0):
        if (base is not None):
            raise ValueError('CIDv0 cannot be multibase-encoded, please set multibase=None.')
        return base58btc.encode(bytes(self))
    if ((base is None) or (base == self.base)):
        base = self.base
    elif isinstance(base, str):
        base = multibase.get(base)
    else:
        multibase.validate_multibase(base)
    return base.encode(bytes(self))