<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def real_dtype(dtype, default=None):
 """Return the real counterpart of ``dtype`` if existing. Parameters dtype : Real or complex floating point data type. It can be given in any way the `numpy.dtype` constructor understands. default : Object to be returned if no real counterpart is found for ``dtype``, except for ``None``, in which case an error is raised. Returns ------- real_dtype : `numpy.dtype` The real counterpart of ``dtype``. Raises ------ ValueError if there is no real counterpart to the given data type and ``default == None``. See Also -------- complex_dtype Examples -------- Convert scalar dtypes: dtype('float64') dtype('float32') dtype('float64') Dtypes with shape are also supported: dtype(('<f8', (3,))) dtype(('<f4', (3,))) """

    dtype, dtype_in = np.dtype(dtype), dtype

    if is_real_floating_dtype(dtype):
        return dtype

    try:
        real_base_dtype = TYPE_MAP_C2R[dtype.base]
    except KeyError:
        if default is not None:
            return default
        else:
            raise ValueError('no real counterpart exists for `dtype` {}'
                             ''.format(dtype_repr(dtype_in)))
    else:
        return np.dtype((real_base_dtype, dtype.shape))