def mlp_run_real_comparison_montecarlo(dataset: cvnn.dataset.Dataset, open_dataset: Optional[t_path]=None, iterations: int=30, epochs: int=300, batch_size: int=100, display_freq: int=1, optimizer='adam', shape_raw=None, activation: t_activation='cart_relu', output_activation: t_activation=DEFAULT_OUTPUT_ACT, verbose: Union[(bool, int)]=False, do_all: bool=True, polar: Optional[Union[(str, List[Optional[str]], Tuple[Optional[str]])]]=None, dropout: float=0.5, validation_split: float=0.2, validation_data: Optional[Union[(Tuple, data.Dataset)]]=None, capacity_equivalent: bool=True, equiv_technique: str='ratio', shuffle: bool=True, tensorboard: bool=False, do_conf_mat: bool=False, plot_data: bool=True) -> str:
    "\n    This function is used to compare CVNN vs RVNN performance over any dataset.\n    1. Automatically creates two Multi-Layer Perceptrons (MLP), one complex and one real.\n    2. Runs simulation and compares them.\n    3. Saves several files into ./log/montecarlo/date/of/run/\n        3.1. run_summary.txt: Summary of the run models and data\n        3.2. run_data.csv: Full information of performance of iteration of each model at each epoch\n        3.3. complex_network_statistical_result.csv: Statistical results of all iterations of CVNN per epoch\n        3.4. real_network_statistical_result.csv: Statistical results of all iterations of RVNN per epoch\n        3.5. (Optional) `plot/` folder with the corresponding plots generated by MonteCarloAnalyzer.do_all()\n\n    :param dataset: cvnn.dataset.Dataset with the dataset to be used on the training\n    :param open_dataset: (None)\n        If dataset is saved inside a folder and must be opened, path of the Dataset to be opened. Else None (default)\n    :param iterations: Number of iterations to be done for each model\n    :param epochs: Number of epochs for each iteration\n    :param batch_size: Batch size at each iteration\n    :param display_freq: Frequency in terms of epochs of when to do a checkpoint.\n    :param optimizer: Optimizer to be used. Keras optimizers are not allowed.\n            Can be either cvnn.optimizers.Optimizer or a string listed in opt_dispatcher.\n    :param shape_raw: List of sizes of each hidden layer.\n        For example [64] will generate a CVNN with one hidden layer of size 64.\n        Default None will default to example.\n    :param activation: Activation function to be used at each hidden layer\n    :param verbose: Different modes according to number:\n            - 0 or 'silent': No output at all\n            - 1 or False: Progress bar per iteration\n            - 2 or True or 'debug': Progress bar per epoch\n    :param polar: Boolean weather the RVNN should receive real and imaginary part (False) or amplitude and phase (True)\n    :param do_all: If true (default) it creates a `plot/` folder with the plots generated by MonteCarloAnalyzer.do_all()\n    :param dropout: (float) Dropout to be used at each hidden layer. If None it will not use any dropout.\n    :param validation_split: Float between 0 and 1.\n            Percentage of the input data to be used as test set (the rest will be use as train set)\n            Default: 0.0 (No validation set).\n            This input is ignored if validation_data is given.\n    :param validation_data: Data on which to evaluate the loss and any model metrics at the end of each epoch.\n        The model will not be trained on this data. This parameter takes precedence over validation_split.\n        It can be:\n            - tuple (x_val, y_val) of Numpy arrays or tensors. Preferred data type (less overhead).\n            - A tf.data dataset.\n    :param capacity_equivalent: An equivalent model can be equivalent in terms of layer neurons or\n                        trainable parameters (capacity equivalent according to: https://arxiv.org/abs/1811.12351)\n            - True, it creates a capacity-equivalent model in terms of trainable parameters\n            - False, it will double all layer size (except the last one if classifier=True)\n    :param equiv_technique: Used to define the strategy of the capacity equivalent model.\n        This parameter is ignored if capacity_equivalent=False\n        - 'ratio': neurons_real_valued_layer[i] = r * neurons_complex_valued_layer[i], 'r' constant for all 'i'\n        - 'alternate': Method described in https://arxiv.org/abs/1811.12351 where one alternates between\n                multiplying by 2 or 1. Special case on the middle is treated as a compromise between the two.\n    :param shuffle: TODO\n    :return: (string) Full path to the run_data.csv generated file.\n        It can be used by cvnn.data_analysis.SeveralMonteCarloComparison to compare several runs.\n    "
    if (shape_raw is None):
        shape_raw = [64]
    if open_dataset:
        dataset = dp.OpenDataset(open_dataset)
    input_size = dataset.x.shape[1]
    output_size = dataset.y.shape[1]
    complex_network = get_mlp(input_size=input_size, output_size=output_size, shape_raw=shape_raw, activation=activation, dropout=dropout, output_activation=output_activation, optimizer=optimizer)
    monte_carlo = RealVsComplex(complex_network, capacity_equivalent=capacity_equivalent, equiv_technique=equiv_technique)
    monte_carlo.output_config['tensorboard'] = tensorboard
    monte_carlo.output_config['plot_all'] = do_all
    monte_carlo.output_config['excel_summary'] = False
    monte_carlo.output_config['confusion_matrix'] = do_conf_mat
    if plot_data:
        dataset.plot_data(overlapped=True, showfig=False, save_path=monte_carlo.monte_carlo_analyzer.path, library='matplotlib')
    sleep(1)
    monte_carlo.run(dataset.x, dataset.y, iterations=iterations, epochs=epochs, batch_size=batch_size, display_freq=display_freq, shuffle=shuffle, verbose=verbose, data_summary=dataset.summary(), real_cast_modes=polar, validation_split=validation_split, validation_data=validation_data)
    max_epoch = monte_carlo.pandas_full_data['epoch'].max()
    epoch_filter = (monte_carlo.pandas_full_data['epoch'] == max_epoch)
    complex_filter = (monte_carlo.pandas_full_data['network'] == 'complex_network')
    real_filter = (monte_carlo.pandas_full_data['network'] == 'real_network')
    complex_last_epochs = monte_carlo.pandas_full_data[(epoch_filter & complex_filter)]
    real_last_epochs = monte_carlo.pandas_full_data[(epoch_filter & real_filter)]
    complex_median_train = complex_last_epochs['accuracy'].median()
    real_median_train = real_last_epochs['accuracy'].median()
    try:
        complex_median = complex_last_epochs['val_accuracy'].median()
        real_median = real_last_epochs['val_accuracy'].median()
        complex_err = median_error(complex_last_epochs['val_accuracy'].quantile(0.75), complex_last_epochs['val_accuracy'].quantile(0.25), iterations)
        real_err = median_error(real_last_epochs['val_accuracy'].quantile(0.75), real_last_epochs['val_accuracy'].quantile(0.25), iterations)
        winner = ('CVNN' if (complex_median > real_median) else 'RVNN')
    except KeyError:
        complex_median = None
        real_median = None
        complex_err = median_error(complex_last_epochs['accuracy'].quantile(0.75), complex_last_epochs['accuracy'].quantile(0.25), iterations)
        real_err = median_error(real_last_epochs['accuracy'].quantile(0.75), real_last_epochs['accuracy'].quantile(0.25), iterations)
        if (complex_median_train > real_median_train):
            winner = 'CVNN'
        elif (complex_median_train == real_median_train):
            winner = None
        else:
            winner = 'RVNN'
    _save_rvnn_vs_cvnn_montecarlo_log(iterations=iterations, path=str(monte_carlo.monte_carlo_analyzer.path), dataset_name=dataset.dataset_name, optimizer=str(complex_network.optimizer.__class__), loss=str(complex_network.loss.__class__), hl=str(len(shape_raw)), shape=str(shape_raw), dropout=str(dropout), num_classes=str(dataset.y.shape[1]), polar_mode=str(polar), activation=activation, dataset_size=str(dataset.x.shape[0]), feature_size=str(dataset.x.shape[1]), epochs=epochs, batch_size=batch_size, winner=winner, complex_median=complex_median, real_median=real_median, complex_median_train=complex_median_train, real_median_train=real_median_train, complex_err=complex_err, real_err=real_err, filename='./log/mlp_montecarlo_summary.xlsx')
    return str((monte_carlo.monte_carlo_analyzer.path / 'run_data.csv'))
This function is used to compare CVNN vs RVNN performance over any dataset.
1. Automatically creates two Multi-Layer Perceptrons (MLP), one complex and one real.
2. Runs simulation and compares them.
3. Saves several files into ./log/montecarlo/date/of/run/
    3.1. run_summary.txt: Summary of the run models and data
    3.2. run_data.csv: Full information of performance of iteration of each model at each epoch
    3.3. complex_network_statistical_result.csv: Statistical results of all iterations of CVNN per epoch
    3.4. real_network_statistical_result.csv: Statistical results of all iterations of RVNN per epoch
    3.5. (Optional) `plot/` folder with the corresponding plots generated by MonteCarloAnalyzer.do_all()

:param dataset: cvnn.dataset.Dataset with the dataset to be used on the training
:param open_dataset: (None)
    If dataset is saved inside a folder and must be opened, path of the Dataset to be opened. Else None (default)
:param iterations: Number of iterations to be done for each model
:param epochs: Number of epochs for each iteration
:param batch_size: Batch size at each iteration
:param display_freq: Frequency in terms of epochs of when to do a checkpoint.
:param optimizer: Optimizer to be used. Keras optimizers are not allowed.
        Can be either cvnn.optimizers.Optimizer or a string listed in opt_dispatcher.
:param shape_raw: List of sizes of each hidden layer.
    For example [64] will generate a CVNN with one hidden layer of size 64.
    Default None will default to example.
:param activation: Activation function to be used at each hidden layer
:param verbose: Different modes according to number:
        - 0 or 'silent': No output at all
        - 1 or False: Progress bar per iteration
        - 2 or True or 'debug': Progress bar per epoch
:param polar: Boolean weather the RVNN should receive real and imaginary part (False) or amplitude and phase (True)
:param do_all: If true (default) it creates a `plot/` folder with the plots generated by MonteCarloAnalyzer.do_all()
:param dropout: (float) Dropout to be used at each hidden layer. If None it will not use any dropout.
:param validation_split: Float between 0 and 1.
        Percentage of the input data to be used as test set (the rest will be use as train set)
        Default: 0.0 (No validation set).
        This input is ignored if validation_data is given.
:param validation_data: Data on which to evaluate the loss and any model metrics at the end of each epoch.
    The model will not be trained on this data. This parameter takes precedence over validation_split.
    It can be:
        - tuple (x_val, y_val) of Numpy arrays or tensors. Preferred data type (less overhead).
        - A tf.data dataset.
:param capacity_equivalent: An equivalent model can be equivalent in terms of layer neurons or
                    trainable parameters (capacity equivalent according to: https://arxiv.org/abs/1811.12351)
        - True, it creates a capacity-equivalent model in terms of trainable parameters
        - False, it will double all layer size (except the last one if classifier=True)
:param equiv_technique: Used to define the strategy of the capacity equivalent model.
    This parameter is ignored if capacity_equivalent=False
    - 'ratio': neurons_real_valued_layer[i] = r * neurons_complex_valued_layer[i], 'r' constant for all 'i'
    - 'alternate': Method described in https://arxiv.org/abs/1811.12351 where one alternates between
            multiplying by 2 or 1. Special case on the middle is treated as a compromise between the two.
:param shuffle: TODO
:return: (string) Full path to the run_data.csv generated file.
    It can be used by cvnn.data_analysis.SeveralMonteCarloComparison to compare several runs.
def mlp_run_real_comparison_montecarlo(dataset: cvnn.dataset.Dataset, open_dataset: Optional[t_path]=None, iterations: int=30, epochs: int=300, batch_size: int=100, display_freq: int=1, optimizer='adam', shape_raw=None, activation: t_activation='cart_relu', output_activation: t_activation=DEFAULT_OUTPUT_ACT, verbose: Union[(bool, int)]=False, do_all: bool=True, polar: Optional[Union[(str, List[Optional[str]], Tuple[Optional[str]])]]=None, dropout: float=0.5, validation_split: float=0.2, validation_data: Optional[Union[(Tuple, data.Dataset)]]=None, capacity_equivalent: bool=True, equiv_technique: str='ratio', shuffle: bool=True, tensorboard: bool=False, do_conf_mat: bool=False, plot_data: bool=True) -> str:
    "\n    This function is used to compare CVNN vs RVNN performance over any dataset.\n    1. Automatically creates two Multi-Layer Perceptrons (MLP), one complex and one real.\n    2. Runs simulation and compares them.\n    3. Saves several files into ./log/montecarlo/date/of/run/\n        3.1. run_summary.txt: Summary of the run models and data\n        3.2. run_data.csv: Full information of performance of iteration of each model at each epoch\n        3.3. complex_network_statistical_result.csv: Statistical results of all iterations of CVNN per epoch\n        3.4. real_network_statistical_result.csv: Statistical results of all iterations of RVNN per epoch\n        3.5. (Optional) `plot/` folder with the corresponding plots generated by MonteCarloAnalyzer.do_all()\n\n    :param dataset: cvnn.dataset.Dataset with the dataset to be used on the training\n    :param open_dataset: (None)\n        If dataset is saved inside a folder and must be opened, path of the Dataset to be opened. Else None (default)\n    :param iterations: Number of iterations to be done for each model\n    :param epochs: Number of epochs for each iteration\n    :param batch_size: Batch size at each iteration\n    :param display_freq: Frequency in terms of epochs of when to do a checkpoint.\n    :param optimizer: Optimizer to be used. Keras optimizers are not allowed.\n            Can be either cvnn.optimizers.Optimizer or a string listed in opt_dispatcher.\n    :param shape_raw: List of sizes of each hidden layer.\n        For example [64] will generate a CVNN with one hidden layer of size 64.\n        Default None will default to example.\n    :param activation: Activation function to be used at each hidden layer\n    :param verbose: Different modes according to number:\n            - 0 or 'silent': No output at all\n            - 1 or False: Progress bar per iteration\n            - 2 or True or 'debug': Progress bar per epoch\n    :param polar: Boolean weather the RVNN should receive real and imaginary part (False) or amplitude and phase (True)\n    :param do_all: If true (default) it creates a `plot/` folder with the plots generated by MonteCarloAnalyzer.do_all()\n    :param dropout: (float) Dropout to be used at each hidden layer. If None it will not use any dropout.\n    :param validation_split: Float between 0 and 1.\n            Percentage of the input data to be used as test set (the rest will be use as train set)\n            Default: 0.0 (No validation set).\n            This input is ignored if validation_data is given.\n    :param validation_data: Data on which to evaluate the loss and any model metrics at the end of each epoch.\n        The model will not be trained on this data. This parameter takes precedence over validation_split.\n        It can be:\n            - tuple (x_val, y_val) of Numpy arrays or tensors. Preferred data type (less overhead).\n            - A tf.data dataset.\n    :param capacity_equivalent: An equivalent model can be equivalent in terms of layer neurons or\n                        trainable parameters (capacity equivalent according to: https://arxiv.org/abs/1811.12351)\n            - True, it creates a capacity-equivalent model in terms of trainable parameters\n            - False, it will double all layer size (except the last one if classifier=True)\n    :param equiv_technique: Used to define the strategy of the capacity equivalent model.\n        This parameter is ignored if capacity_equivalent=False\n        - 'ratio': neurons_real_valued_layer[i] = r * neurons_complex_valued_layer[i], 'r' constant for all 'i'\n        - 'alternate': Method described in https://arxiv.org/abs/1811.12351 where one alternates between\n                multiplying by 2 or 1. Special case on the middle is treated as a compromise between the two.\n    :param shuffle: TODO\n    :return: (string) Full path to the run_data.csv generated file.\n        It can be used by cvnn.data_analysis.SeveralMonteCarloComparison to compare several runs.\n    "
    if (shape_raw is None):
        shape_raw = [64]
    if open_dataset:
        dataset = dp.OpenDataset(open_dataset)
    input_size = dataset.x.shape[1]
    output_size = dataset.y.shape[1]
    complex_network = get_mlp(input_size=input_size, output_size=output_size, shape_raw=shape_raw, activation=activation, dropout=dropout, output_activation=output_activation, optimizer=optimizer)
    monte_carlo = RealVsComplex(complex_network, capacity_equivalent=capacity_equivalent, equiv_technique=equiv_technique)
    monte_carlo.output_config['tensorboard'] = tensorboard
    monte_carlo.output_config['plot_all'] = do_all
    monte_carlo.output_config['excel_summary'] = False
    monte_carlo.output_config['confusion_matrix'] = do_conf_mat
    if plot_data:
        dataset.plot_data(overlapped=True, showfig=False, save_path=monte_carlo.monte_carlo_analyzer.path, library='matplotlib')
    sleep(1)
    monte_carlo.run(dataset.x, dataset.y, iterations=iterations, epochs=epochs, batch_size=batch_size, display_freq=display_freq, shuffle=shuffle, verbose=verbose, data_summary=dataset.summary(), real_cast_modes=polar, validation_split=validation_split, validation_data=validation_data)
    max_epoch = monte_carlo.pandas_full_data['epoch'].max()
    epoch_filter = (monte_carlo.pandas_full_data['epoch'] == max_epoch)
    complex_filter = (monte_carlo.pandas_full_data['network'] == 'complex_network')
    real_filter = (monte_carlo.pandas_full_data['network'] == 'real_network')
    complex_last_epochs = monte_carlo.pandas_full_data[(epoch_filter & complex_filter)]
    real_last_epochs = monte_carlo.pandas_full_data[(epoch_filter & real_filter)]
    complex_median_train = complex_last_epochs['accuracy'].median()
    real_median_train = real_last_epochs['accuracy'].median()
    try:
        complex_median = complex_last_epochs['val_accuracy'].median()
        real_median = real_last_epochs['val_accuracy'].median()
        complex_err = median_error(complex_last_epochs['val_accuracy'].quantile(0.75), complex_last_epochs['val_accuracy'].quantile(0.25), iterations)
        real_err = median_error(real_last_epochs['val_accuracy'].quantile(0.75), real_last_epochs['val_accuracy'].quantile(0.25), iterations)
        winner = ('CVNN' if (complex_median > real_median) else 'RVNN')
    except KeyError:
        complex_median = None
        real_median = None
        complex_err = median_error(complex_last_epochs['accuracy'].quantile(0.75), complex_last_epochs['accuracy'].quantile(0.25), iterations)
        real_err = median_error(real_last_epochs['accuracy'].quantile(0.75), real_last_epochs['accuracy'].quantile(0.25), iterations)
        if (complex_median_train > real_median_train):
            winner = 'CVNN'
        elif (complex_median_train == real_median_train):
            winner = None
        else:
            winner = 'RVNN'
    _save_rvnn_vs_cvnn_montecarlo_log(iterations=iterations, path=str(monte_carlo.monte_carlo_analyzer.path), dataset_name=dataset.dataset_name, optimizer=str(complex_network.optimizer.__class__), loss=str(complex_network.loss.__class__), hl=str(len(shape_raw)), shape=str(shape_raw), dropout=str(dropout), num_classes=str(dataset.y.shape[1]), polar_mode=str(polar), activation=activation, dataset_size=str(dataset.x.shape[0]), feature_size=str(dataset.x.shape[1]), epochs=epochs, batch_size=batch_size, winner=winner, complex_median=complex_median, real_median=real_median, complex_median_train=complex_median_train, real_median_train=real_median_train, complex_err=complex_err, real_err=real_err, filename='./log/mlp_montecarlo_summary.xlsx')
    return str((monte_carlo.monte_carlo_analyzer.path / 'run_data.csv'))