from typing import Any


def to_bytes(data: Any, encoding: str = "utf-8") -> bytes:
    """
    Returns the bytes representation of the provided data.

    :param data: Data to be transformed.
    :type data: Any

    :param encoding: Encoding of the bytes encoding, defaults to "utf-8".
    :type encoding: str, optional

    :return: Bytes representation of the provided data.
    :rtype: bytes
    """

    if isinstance(data, bytes) or data is None:
        return data

    if isinstance(data, str):
        return data.encode(encoding)

    if isinstance(data, (int, float)):
        return str(data).encode(encoding)

    return bytes(data, encoding=encoding)