def _replace_with_new_dims(  # type: ignore
        self: T,
        variables: 'OrderedDict[Any, Variable]' = None,
        coord_names: set = None,
        attrs: 'Optional[OrderedDict]' = __default,
        indexes: 'Optional[OrderedDict[Any, pd.Index]]' = __default,
        inplace: bool = False,
    ) -> T:
        """Replace variables with recalculated dimensions."""
        dims = dict(calculate_dimensions(variables))
        return self._replace(
            variables, coord_names, dims, attrs, indexes, inplace=inplace)