from __future__ import absolute_import
from .version import __version__

from .utils.const import *
from .utils.ios import loadyaml, saveyaml, loadjson, loadmat, savemat, loadh5, saveh5, mvkeyh5, loadbin, savebin
from .utils.image import imread, imsave, imadjust, imadjustlog, histeq, imresize
from .utils.file import data_path, pkg_path, copyfile, copyfiles, listxfile, pathjoin, fileparts, writetxt, readtxt, readnum, readsec, fopen
from .utils.convert import value2unit, str2hash, file2hash, dict2str, str2bool, str2list, str2tuple, str2num, str2sec, int2bstr, bstr2int
from .utils.colormaps import cmaps, viridis, parula
from .utils.colors import rgb2gray, gray2rgb, DISTINCT_COLORS_HEX, DISTINCT_COLORS_RGB, DISTINCT_COLORS_CMYK, DISTINCT_COLORS_RGB_NORM, BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS
from .utils.plot_show import cplot, plots, Plots, plot, imshow, mesh, mshow

from .base.baseops import sub2ind, ind2sub, dimpos, dimpermute, dimreduce, dimmerge, rmcdim, upkeys, dreplace, dmka, cat, argsort, argmin, argmax, min, max
from .base.arrayops import sl, ta, cut, arraycomb, permute, reduce, swap, merge, roll
from .base.mathops import db2mag, mag2db, fnab, ebeo, sinc, nextpow2, prevpow2, ematmul, matmul, c2r, r2c, conj, real, imag, angle, abs, pow, mean, var, std, cov, dot, log
from .base.randomfunc import setseed, randgrid, randperm, randperm2d
from .base.typevalue import peakvalue, dtypes
from .base.geometry import rad2deg, deg2rad, pol2car, car2pol, sph2car, car2sph

from .dsp.ffts import padfft, freq, fftfreq, fftshift, ifftshift, fft, ifft
from .dsp.convolution import cutfftconv1, fftconv1, convn
from .dsp.correlation import cutfftcorr1, fftcorr1, xcorr, acorr, accc
from .dsp.normalsignals import rect, chirp, dechirp
from .dsp.interpolation import interpolate, interpolatec
from .dsp.polynomialfit import polyfit, polyval, rmlinear
from .dsp.function_base import unwrap, unwrap2
from .dsp.window_function import window, windowing
from .dsp.find_peaks import localmax1d, localmax2d, localmax3d, filtpeaks, findpeaks

from .evaluation.classification import categorical2onehot, onehot2categorical, accuracy, confusion, kappa, plot_confusion
from .evaluation.correlation import cossim, peacor, eigveccor
from .evaluation.contrast import contrast
from .evaluation.entropy import entropy
from .evaluation.classification import accuracy
from .evaluation.norm import norm
from .evaluation.error import mse, sse, mae, sae, nmse, nsse, nmae, nsae
from .evaluation.snrs import snr
from .evaluation.retrieval import true_positive, true_negative, \
    false_positive, false_negative, \
    precision, recall, sensitivity, selectivity, fmeasure, false_alarm_rate, miss_alarm_rate
from .evaluation.similarity import jaccard_index, dice_coeff
from .evaluation.ssims import gaussian_filter, ssim, msssim
from .evaluation.generic import geval, eprint, eplot

from .misc.transform import rotmat, zscore, scale, quantization, db20, ct2rt, rt2ct
from .misc.mapping_operation import dynrng, mapping
from .misc.sampling import slidegrid, dnsampling, sample_tensor, shuffle_tensor, split_tensor, cut_tensor, tensor2patch, patch2tensor, read_samples
from .misc.draw_shapes import draw_rectangle, draw_eclipse
from .misc.noising import awgns, awgns2, imnoise, awgn, wgn

from .datasets.mnist import read_mnist
from .datasets.mstar import mstar_header, mstar_raw
from .datasets.signals import cosine, CosineTask

from .dataloaders.meta_dataloader import MetaDataLoader

from .nn.activations import linear, sigmoid, tanh, softplus, softsign, elu, relu, relu6, selu, crelu, leaky_relu

from .linalg.orthogonalization import orth
from .linalg.decomposition import svd_rank, eig, eigvals, sqrtm

from .layerfunction.cplxfunc import csign, csoftshrink, softshrink
from .layerfunction.complex_functions import complex_relu, complex_leaky_relu, complex_max_pool2d, complex_dropout, complex_dropout2d, complex_upsample

from .ml.reduction_pca import pcat, pcapc, pca

from .module.dsp.convolution import FFTConv1, Conv1, MaxPool1, Conv2, MaxPool2
from .module.dsp.interpolation import Interp1
from .module.dsp.polynomialfit import PolyFit

from .module.misc.transform import Standardization


from .module.evaluation.contrast import Contrast
from .module.evaluation.entropy import Entropy
from .module.evaluation.correlation import CosSim, PeaCor, EigVecCor
from .module.evaluation.channel import ChnlCapCor
from .module.evaluation.norm import Fnorm, Pnorm
from .module.evaluation.error import MSE, SSE, MAE, SAE, NMSE, NSSE, NMAE, NSAE
from .module.evaluation.ssims import SSIM, MSSSIM
from .module.evaluation.variation import TotalVariation
from .module.evaluation.retrieval import Dice, Jaccard, F1

from .module.loss.correlation import CosSimLoss, PeaCorLoss, EigVecCorLoss
from .module.loss.contrast import ContrastLoss, NegativeContrastLoss, ReciprocalContrastLoss
from .module.loss.entropy import EntropyLoss
from .module.loss.norm import FnormLoss, PnormLoss
from .module.loss.perceptual import RandomProjectionLoss
from .module.loss.retrieval import DiceLoss, JaccardLoss, F1Loss
from .module.loss.variation import TotalVariation
from .module.loss.fourier import FourierLoss, FourierAmplitudeLoss, FourierPhaseLoss, FourierNormLoss
from .module.loss.error import MSELoss, SSELoss, MAELoss, SAELoss, NMSELoss, NSSELoss, NMAELoss, NSAELoss
from .module.loss.sparse_metric import LogSparseLoss, FourierLogSparseLoss


from .module.layers.balanceconv2d import BalaConv2d
from .module.layers.cnnsize import conv_size, ConvSize1d, ConvTransposeSize1d, PoolSize1d, UnPoolSize1d, ConvSize2d, ConvTransposeSize2d, PoolSize2d, UnPoolSize2d
from .module.layers.edge import EdgeDetector, EdgeFeatureExtractor
from .module.layers.pool import MeanSquarePool2d, PnormPool2d
from .module.layers.complex_layers import ComplexSequential, ComplexMaxPool2d, ComplexMaxPool1d, ComplexDropout,  ComplexDropout2d, ComplexReLU, ComplexLeakyReLU, ComplexConvTranspose2d, ComplexConv2d, ComplexConvTranspose1d, ComplexConv1d, ComplexLinear, ComplexUpsample, NaiveComplexBatchNorm1d, NaiveComplexBatchNorm2d, NaiveComplexBatchNorm1d, ComplexBatchNorm2d, ComplexBatchNorm1d, ComplexConv1, ComplexMaxPool1, ComplexConv2, ComplexMaxPool2
from .module.layers.phase_convolution import PhaseConv1d, PhaseConv2d, ComplexPhaseConv1d, ComplexPhaseConv2d, PhaseConvTranspose1d, PhaseConvTranspose2d, ComplexPhaseConvTranspose1d, ComplexPhaseConvTranspose2d
from .module.layers.fft_layers import FFTLayer1d
from .module.layers.convolution import FFTConv1, Conv1, Conv2, MaxPool1, MaxPool2
from .module.layers.consistency_layers import DataConsistency2d
from .module.layers.flow_layers import ActNorm, InvConv2d, InvConv2dLU, ZeroConv2d, AffineCoupling, Flow, FlowBlock, Glow
from .module.layers.conv_lstms import ConvLSTMCell, ConvLSTM

from .spl import voptimizer
from .spl import spfunction

from .optim.learning_rate import gammalr, LrFinder
from .optim.lr_scheduler import GaussianLR, MountainLR
from .optim.save_load import device_transfer, save_model, load_model, get_parameters
from .optim.solver import train_epoch, valid_epoch, test_epoch, demo_epoch
from .optim.mamls_solver import MAML, MetaSGD, mamls_train_epoch, mamls_valid_epoch, mamls_test_epoch

from .summary.loss_log import LossLog
from .summary.modelinfo import profile

from .diagnose.plotgradflow import plot_gradflow_v1, plot_gradflow_v2



