def METHOD_NAME(obj: Union[xr.Variable, xr.DataArray, xr.Dataset]) -> VariableLike:
    """Convert an xarray object to the corresponding scipp object.
    Attributes named `"units"` are used to set the units of the Variables.
    All other DataArray attributes are kept, but attributes of Variables, Coordinates
    and Datasets are dropped.
    Parameters
    ----------
    obj:
        The xarray object to convert.
    Returns
    -------
    :
        The converted scipp object.
    See Also
    --------
    scipp.compat.to_xarray
    """
    import xarray as xr
    if isinstance(obj, xr.Variable):
        return _from_xarray_variable(obj)
    elif isinstance(obj, xr.DataArray):
        return _from_xarray_dataarray(obj)
    elif isinstance(obj, xr.Dataset):
        return _from_xarray_dataset(obj)
    else:
        raise ValueError(f"from_xarray: cannot convert type '{type(obj)}'")