code: def validate_dtype_freq(dtype, freq):
      
      if freq is not None:
          freq = frequencies.to_offset(freq)
  
      if dtype is not None:
          dtype = pandas_dtype(dtype)
          if not is_period_dtype(dtype):
              raise ValueError('dtype must be PeriodDtype')
          if freq is None:
              freq = dtype.freq
          elif freq != dtype.freq:
              raise IncompatibleFrequency('specified freq and dtype '
                                          'are different')
      return freq
docs: If both a dtype and a freq are available, ensure they match.  If only
      dtype is available, extract the implied freq.
  
      Parameters
      ----------
      dtype : dtype
      freq : DateOffset or None
  
      Returns
      -------
      freq : DateOffset
  
      Raises
      ------
      ValueError : non-period dtype
      IncompatibleFrequency : mismatch between dtype and freq