// </snippet_train_return>

    // <snippet_trainlabels>
    private static async Task <Guid> TrainModelWithLabelsAsync(
        FormRecognizerClient trainingClient, string trainingDataUrl)
    {
        CustomFormModel model = await trainingClient
                                .StartTrainingAsync(new Uri(trainingDataUrl), useTrainingLabels : true)
                                .WaitForCompletionAsync();

        Console.WriteLine($"Custom Model Info:");
        Console.WriteLine($"    Model Id: {model.ModelId}");
        Console.WriteLine($"    Model Status: {model.Status}");
        Console.WriteLine($"    Training model started on: {model.TrainingStartedOn}");
        Console.WriteLine($"    Training model completed on: {model.TrainingCompletedOn}");
        // </snippet_trainlabels>
        // <snippet_trainlabels_response>
        foreach (CustomFormSubmodel submodel in model.Submodels)
        {
            Console.WriteLine($"Submodel Form Type: {submodel.FormType}");
            foreach (CustomFormModelField field in submodel.Fields.Values)
            {
                Console.Write($"    FieldName: {field.Name}");
                if (field.Label != null)
                {
                    Console.Write($", FieldLabel: {field.Label}");
                }
                Console.WriteLine("");
            }
        }
        return(model.ModelId);
    }
    // </snippet_analyze_response>

    // <snippet_manage>
    private static async Task ManageModels(
        FormRecognizerClient trainingClient, string trainingFileUrl)
    {
        // </snippet_manage>
        // <snippet_manage_model_count>
        // Check number of models in the FormRecognizer account, 
        // and the maximum number of models that can be stored.
        AccountProperties accountProperties = trainingClient.GetAccountProperties();
        Console.WriteLine($"Account has {accountProperties.CustomModelCount} models.");
        Console.WriteLine($"It can have at most {accountProperties.CustomModelLimit}" +
            $" models.");
        // </snippet_manage_model_count>

        // <snippet_manage_model_list>
        // List the first ten or fewer models currently stored in the account.
        Pageable<CustomFormModelInfo> models = trainingClient.GetModelInfos();
        
        foreach (CustomFormModelInfo modelInfo in models.Take(10))
        {
            Console.WriteLine($"Custom Model Info:");
            Console.WriteLine($"    Model Id: {modelInfo.ModelId}");
            Console.WriteLine($"    Model Status: {modelInfo.Status}");
            Console.WriteLine($"    Created On: {modelInfo.CreatedOn}");
            Console.WriteLine($"    Last Modified: {modelInfo.LastModified}");
        }
        // </snippet_manage_model_list>

        // <snippet_manage_model_get>
        // Create a new model to store in the account
        CustomFormModel model = await trainingClient.StartTrainingAsync(
            new Uri(trainingFileUrl)).WaitForCompletionAsync();
        
        // Get the model that was just created
        CustomFormModel modelCopy = trainingClient.GetCustomModel(model.ModelId);
        
        Console.WriteLine($"Custom Model {modelCopy.ModelId} recognizes the following" +
            " form types:");
        
        foreach (CustomFormSubModel subModel in modelCopy.Models)
        {
            Console.WriteLine($"SubModel Form Type: {subModel.FormType}");
            foreach (CustomFormModelField field in subModel.Fields.Values)
            {
                Console.Write($"    FieldName: {field.Name}");
                if (field.Label != null)
                {
                    Console.Write($", FieldLabel: {field.Label}");
                }
                Console.WriteLine("");
            }
        }
        // </snippet_manage_model_get>

        // <snippet_manage_model_delete>
        // Delete the model from the account.
        trainingClient.DeleteModel(model.ModelId);
    }