// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.ImageModelSettingsClassification;
import com.azure.resourcemanager.machinelearning.models.InputDeliveryMode;
import com.azure.resourcemanager.machinelearning.models.LearningRateScheduler;
import com.azure.resourcemanager.machinelearning.models.MLFlowModelJobInput;
import com.azure.resourcemanager.machinelearning.models.StochasticOptimizer;
import org.junit.jupiter.api.Assertions;

public final class ImageModelSettingsClassificationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ImageModelSettingsClassification model =
            BinaryData
                .fromString(
                    "{\"trainingCropSize\":1924497192,\"validationCropSize\":919883073,\"validationResizeSize\":1735818040,\"weightedLoss\":2030366014,\"advancedSettings\":\"tuicds\",\"amsGradient\":true,\"augmentations\":\"m\",\"beta1\":59.436913,\"beta2\":62.807377,\"checkpointFrequency\":1080891031,\"checkpointModel\":{\"jobInputType\":\"mlflow_model\",\"mode\":\"Download\",\"uri\":\"rgyngydgrpxnca\",\"description\":\"qao\"},\"checkpointRunId\":\"jrkc\",\"distributed\":true,\"earlyStopping\":true,\"earlyStoppingDelay\":1511007702,\"earlyStoppingPatience\":1521830595,\"enableOnnxNormalization\":true,\"evaluationFrequency\":1183182643,\"gradientAccumulationStep\":588395160,\"layersToFreeze\":1092712252,\"learningRate\":63.37043,\"learningRateScheduler\":\"WarmupCosine\",\"modelName\":\"gxhqfgqkayejs\",\"momentum\":38.807606,\"nesterov\":true,\"numberOfEpochs\":390611386,\"numberOfWorkers\":883853554,\"optimizer\":\"None\",\"randomSeed\":9965556,\"stepLRGamma\":33.88037,\"stepLRStepSize\":1346771342,\"trainingBatchSize\":1977652281,\"validationBatchSize\":503751381,\"warmupCosineLRCycles\":23.360283,\"warmupCosineLRWarmupEpochs\":1142072535,\"weightDecay\":68.338776}")
                .toObject(ImageModelSettingsClassification.class);
        Assertions.assertEquals("tuicds", model.advancedSettings());
        Assertions.assertEquals(true, model.amsGradient());
        Assertions.assertEquals("m", model.augmentations());
        Assertions.assertEquals(59.436913F, model.beta1());
        Assertions.assertEquals(62.807377F, model.beta2());
        Assertions.assertEquals(1080891031, model.checkpointFrequency());
        Assertions.assertEquals("qao", model.checkpointModel().description());
        Assertions.assertEquals(InputDeliveryMode.DOWNLOAD, model.checkpointModel().mode());
        Assertions.assertEquals("rgyngydgrpxnca", model.checkpointModel().uri());
        Assertions.assertEquals("jrkc", model.checkpointRunId());
        Assertions.assertEquals(true, model.distributed());
        Assertions.assertEquals(true, model.earlyStopping());
        Assertions.assertEquals(1511007702, model.earlyStoppingDelay());
        Assertions.assertEquals(1521830595, model.earlyStoppingPatience());
        Assertions.assertEquals(true, model.enableOnnxNormalization());
        Assertions.assertEquals(1183182643, model.evaluationFrequency());
        Assertions.assertEquals(588395160, model.gradientAccumulationStep());
        Assertions.assertEquals(1092712252, model.layersToFreeze());
        Assertions.assertEquals(63.37043F, model.learningRate());
        Assertions.assertEquals(LearningRateScheduler.WARMUP_COSINE, model.learningRateScheduler());
        Assertions.assertEquals("gxhqfgqkayejs", model.modelName());
        Assertions.assertEquals(38.807606F, model.momentum());
        Assertions.assertEquals(true, model.nesterov());
        Assertions.assertEquals(390611386, model.numberOfEpochs());
        Assertions.assertEquals(883853554, model.numberOfWorkers());
        Assertions.assertEquals(StochasticOptimizer.NONE, model.optimizer());
        Assertions.assertEquals(9965556, model.randomSeed());
        Assertions.assertEquals(33.88037F, model.stepLRGamma());
        Assertions.assertEquals(1346771342, model.stepLRStepSize());
        Assertions.assertEquals(1977652281, model.trainingBatchSize());
        Assertions.assertEquals(503751381, model.validationBatchSize());
        Assertions.assertEquals(23.360283F, model.warmupCosineLRCycles());
        Assertions.assertEquals(1142072535, model.warmupCosineLRWarmupEpochs());
        Assertions.assertEquals(68.338776F, model.weightDecay());
        Assertions.assertEquals(1924497192, model.trainingCropSize());
        Assertions.assertEquals(919883073, model.validationCropSize());
        Assertions.assertEquals(1735818040, model.validationResizeSize());
        Assertions.assertEquals(2030366014, model.weightedLoss());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ImageModelSettingsClassification model =
            new ImageModelSettingsClassification()
                .withAdvancedSettings("tuicds")
                .withAmsGradient(true)
                .withAugmentations("m")
                .withBeta1(59.436913F)
                .withBeta2(62.807377F)
                .withCheckpointFrequency(1080891031)
                .withCheckpointModel(
                    new MLFlowModelJobInput()
                        .withDescription("qao")
                        .withMode(InputDeliveryMode.DOWNLOAD)
                        .withUri("rgyngydgrpxnca"))
                .withCheckpointRunId("jrkc")
                .withDistributed(true)
                .withEarlyStopping(true)
                .withEarlyStoppingDelay(1511007702)
                .withEarlyStoppingPatience(1521830595)
                .withEnableOnnxNormalization(true)
                .withEvaluationFrequency(1183182643)
                .withGradientAccumulationStep(588395160)
                .withLayersToFreeze(1092712252)
                .withLearningRate(63.37043F)
                .withLearningRateScheduler(LearningRateScheduler.WARMUP_COSINE)
                .withModelName("gxhqfgqkayejs")
                .withMomentum(38.807606F)
                .withNesterov(true)
                .withNumberOfEpochs(390611386)
                .withNumberOfWorkers(883853554)
                .withOptimizer(StochasticOptimizer.NONE)
                .withRandomSeed(9965556)
                .withStepLRGamma(33.88037F)
                .withStepLRStepSize(1346771342)
                .withTrainingBatchSize(1977652281)
                .withValidationBatchSize(503751381)
                .withWarmupCosineLRCycles(23.360283F)
                .withWarmupCosineLRWarmupEpochs(1142072535)
                .withWeightDecay(68.338776F)
                .withTrainingCropSize(1924497192)
                .withValidationCropSize(919883073)
                .withValidationResizeSize(1735818040)
                .withWeightedLoss(2030366014);
        model = BinaryData.fromObject(model).toObject(ImageModelSettingsClassification.class);
        Assertions.assertEquals("tuicds", model.advancedSettings());
        Assertions.assertEquals(true, model.amsGradient());
        Assertions.assertEquals("m", model.augmentations());
        Assertions.assertEquals(59.436913F, model.beta1());
        Assertions.assertEquals(62.807377F, model.beta2());
        Assertions.assertEquals(1080891031, model.checkpointFrequency());
        Assertions.assertEquals("qao", model.checkpointModel().description());
        Assertions.assertEquals(InputDeliveryMode.DOWNLOAD, model.checkpointModel().mode());
        Assertions.assertEquals("rgyngydgrpxnca", model.checkpointModel().uri());
        Assertions.assertEquals("jrkc", model.checkpointRunId());
        Assertions.assertEquals(true, model.distributed());
        Assertions.assertEquals(true, model.earlyStopping());
        Assertions.assertEquals(1511007702, model.earlyStoppingDelay());
        Assertions.assertEquals(1521830595, model.earlyStoppingPatience());
        Assertions.assertEquals(true, model.enableOnnxNormalization());
        Assertions.assertEquals(1183182643, model.evaluationFrequency());
        Assertions.assertEquals(588395160, model.gradientAccumulationStep());
        Assertions.assertEquals(1092712252, model.layersToFreeze());
        Assertions.assertEquals(63.37043F, model.learningRate());
        Assertions.assertEquals(LearningRateScheduler.WARMUP_COSINE, model.learningRateScheduler());
        Assertions.assertEquals("gxhqfgqkayejs", model.modelName());
        Assertions.assertEquals(38.807606F, model.momentum());
        Assertions.assertEquals(true, model.nesterov());
        Assertions.assertEquals(390611386, model.numberOfEpochs());
        Assertions.assertEquals(883853554, model.numberOfWorkers());
        Assertions.assertEquals(StochasticOptimizer.NONE, model.optimizer());
        Assertions.assertEquals(9965556, model.randomSeed());
        Assertions.assertEquals(33.88037F, model.stepLRGamma());
        Assertions.assertEquals(1346771342, model.stepLRStepSize());
        Assertions.assertEquals(1977652281, model.trainingBatchSize());
        Assertions.assertEquals(503751381, model.validationBatchSize());
        Assertions.assertEquals(23.360283F, model.warmupCosineLRCycles());
        Assertions.assertEquals(1142072535, model.warmupCosineLRWarmupEpochs());
        Assertions.assertEquals(68.338776F, model.weightDecay());
        Assertions.assertEquals(1924497192, model.trainingCropSize());
        Assertions.assertEquals(919883073, model.validationCropSize());
        Assertions.assertEquals(1735818040, model.validationResizeSize());
        Assertions.assertEquals(2030366014, model.weightedLoss());
    }
}
