code: def tx_mean(tasmax, freq='YS'):
      r
  
      arr = tasmax.resample(time=freq) if freq else tasmax
      return arr.mean(dim='time', keep_attrs=True)
docs: r"""Mean max temperature
  
      The mean of daily maximum temperature.
  
      Parameters
      ----------
      tasmax : xarray.DataArray
        Maximum daily temperature [℃] or [K]
      freq : str, optional
        Resampling frequency
  
      Returns
      -------
      xarray.DataArray
        Mean of daily maximum temperature.
  
      Notes
      -----
      Let :math:`TX_{ij}` be the maximum temperature at day :math:`i` of period :math:`j`. Then mean
      values in period :math:`j` are given by:
  
      .. math::
  
          TX_{ij} = \frac{ \sum_{i=1}^{I} TX_{ij} }{I}