from typing import Union


def bars_to_atmospheres(bar: float, unit: str) -> Union[float, str]:
    """
    This function converts bar to atm
    Wikipedia reference: https://en.wikipedia.org/wiki/Standard_atmosphere_(unit)
    Wikipedia reference: https://en.wikipedia.org/wiki/Bar_(unit)

    >>> bars_to_atmospheres(36, "bar")
    35.529237601776465
    >>> bars_to_atmospheres("57.6", "bar")
    56.84678016284234
    >>> bars_to_atmospheres(0, "bar")
    0.0
    >>> bars_to_atmospheres(35, "Pa")
    'Invalid unit'
    >>> bars_to_atmospheres("barrs", "bar")
    Traceback (most recent call last):
    ...
    ValueError: could not convert string to float: 'barrs'

    """
    if unit == "bar":
        atm = float(bar) / 1.01325
        return atm
    else:
        return "Invalid unit"