from typing import Union
from typing import Optional


def _decode(data: Union[None, str, bytes], encoding: str) -> Optional[str]:
    """ Encode given `data` with `encoding` format or return string|None.

    Args: 
        data: data to encode.
        encoding: selected encoding of the given `data`.

    Return:
        String representation of the given `data` or None.
    """
    if data is None:
        return None
    else:
        if isinstance(data, str):
            return data
        else:
            return str(data, encoding)