<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def coarsen(self, dim: Optional[Mapping[Hashable, int]] = None, boundary: str = 'exact', side: Union[str, Mapping[Hashable, str]] = 'left', coord_func: str = 'mean', **dim_kwargs: int):
 """ Coarsen object. Parameters dim: dict, optional Mapping from the dimension name to the window size. dim : str Name of the dimension to create the rolling iterator along (e.g., `time`). window : int Size of the moving window. boundary : 'exact' | 'trim' | 'pad' If 'exact', a ValueError will be raised if dimension size is not a multiple of the window size. If 'trim', the excess entries are dropped. If 'pad', NA will be padded. side : 'left' or 'right' or mapping from dimension to 'left' or 'right' coord_func: function (name) that is applied to the coordintes, or a mapping from coordinate name to function (name). Returns ------- Coarsen object (core.rolling.DataArrayCoarsen for DataArray, core.rolling.DatasetCoarsen for Dataset.) Examples -------- Coarsen the long time series by averaging over every four days. <xarray.DataArray (time: 364)> 364. ]) Coordinates: <xarray.DataArray (time: 121)> 361.99449 ]) Coordinates: See Also -------- core.rolling.DataArrayCoarsen core.rolling.DatasetCoarsen """

        dim = either_dict_or_kwargs(dim, dim_kwargs, 'coarsen')
        return self._coarsen_cls(
            self, dim, boundary=boundary, side=side,
            coord_func=coord_func)