code: def tg_max(tas, freq='YS'):
      r
  
      return tas.resample(time=freq).max(dim='time', keep_attrs=True)
docs: r"""Highest mean temperature.
  
      The maximum of daily mean temperature.
  
      Parameters
      ----------
      tas : xarray.DataArray
        Mean daily temperature [℃] or [K]
      freq : str, optional
        Resampling frequency
  
      Returns
      -------
      xarray.DataArray
        Maximum of daily minimum temperature.
  
      Notes
      -----
      Let :math:`TN_{ij}` be the mean temperature at day :math:`i` of period :math:`j`. Then the maximum
      daily mean temperature for period :math:`j` is:
  
      .. math::
  
          TNx_j = max(TN_{ij})