code: def real_dtype(dtype, default=None):
      
      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))
docs: 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:
  
      >>> real_dtype(complex)
      dtype('float64')
      >>> real_dtype('complex64')
      dtype('float32')
      >>> real_dtype(float)
      dtype('float64')
  
      Dtypes with shape are also supported:
  
      >>> real_dtype(np.dtype((complex, (3,))))
      dtype(('<f8', (3,)))
      >>> real_dtype(('complex64', (3,)))
      dtype(('<f4', (3,)))