//  [python]
def run_aucmedi(x_train, y_train, x_val, y_val, architecture, config):
    # Create result directory for architecture
    path_res = os.path.join(config["path_phase"], architecture)
    if not os.path.exists(path_res) : os.mkdir(path_res)

    # Initialize Image Augmentation
    aug = Image_Augmentation(flip=True, rotate=True, brightness=True, contrast=True,
                             saturation=True, hue=True, scale=False, crop=False,
                             grid_distortion=False, compression=False, gamma=False,
                             gaussian_noise=False, gaussian_blur=False,
                             downscaling=False, elastic_transform=False)
    # Define Subfunctions
    sf_list = [Padding(mode="square")]
    # Set activation output to softmax for multi-class classification
    activation_output = "softmax"

    # Initialize architecture
    nn_arch = architecture_dict[architecture](channels=3)
    # Define input shape
    input_shape = nn_arch.input[:-1]

    # Initialize model
    model = Neural_Network(config["nclasses"], channels=3, architecture=nn_arch,
                           workers=config["workers"], multiprocessing=False,
                           batch_queue_size=config["batch_queue_size"],
                           activation_output=activation_output,
                           loss="categorical_crossentropy",
                           metrics=[CategoricalAccuracy(), AUC(100)],
                           pretrained_weights=True)
    # Modify number of transfer learning epochs with frozen model layers
    model.tf_epochs = 10

    # Obtain standardization mode for current architecture
    sf_standardize = supported_standardize_mode[architecture]

    # Initialize training and validation Data Generators
    train_gen = DataGenerator(x_train, config["path_images"], labels=y_train,
                              batch_size=config["batch_size"], img_aug=aug,
                              shuffle=True, subfunctions=sf_list,
                              resize=input_shape, standardize_mode=sf_standardize,
                              grayscale=False, prepare_images=False,
                              sample_weights=None, seed=None,
                              image_format=config["image_format"],
                              workers=config["threads"])
    val_gen = DataGenerator(x_val, config["path_images"], labels=y_val,
                            batch_size=config["batch_size"], img_aug=None,
                            subfunctions=sf_list, shuffle=False,
                            standardize_mode=sf_standardize, resize=input_shape,
                            grayscale=False, prepare_images=False, seed=None,
                            sample_weights=None, workers=config["threads"],
                            image_format=config["image_format"])

    # Define callbacks
    cb_mc = ModelCheckpoint(os.path.join(path_res, "model.best.hdf5"),
                            monitor="val_loss", verbose=1,
                            save_best_only=True, mode="min")
    cb_cl = CSVLogger(os.path.join(path_res, "logs.csv"), separator=',', append=True)
    cb_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.1, patience=5,
                              verbose=1, mode='min', min_lr=1e-7)
    cb_es = EarlyStopping(monitor='val_loss', patience=15, verbose=1)
    callbacks = [cb_mc, cb_cl, cb_lr, cb_es]

    # Train model
    model.train(train_gen, val_gen, class_weights=config["class_weights_dict"],
                epochs=config["epochs"], iterations=config["iterations"],
                callbacks=callbacks, transfer_learning=True)

    # Dump latest model
    model.dump(os.path.join(path_res, "model.last.hdf5"))

    # Garbage collection
    del train_gen
    del val_gen
    del model