text: # Copyright 2021 The Trieste Contributors
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  """
  Utilities for creating (Keras) neural network models to be used in the tests.
  """
  
  from __future__ import annotations
  
  from trieste.data import Dataset
  from trieste.models.keras import GaussianNetwork, KerasEnsemble, get_tensor_spec_from_data
  
  
  def trieste_keras_ensemble_model(
      example_data: Dataset,
      ensemble_size: int,
      independent_normal: bool = False,
  ) -> KerasEnsemble:
  
      input_tensor_spec, output_tensor_spec = get_tensor_spec_from_data(example_data)
  
      networks = [
          GaussianNetwork(
              input_tensor_spec,
              output_tensor_spec,
              hidden_layer_args=[
                  {"units": 32, "activation": "relu"},
                  {"units": 32, "activation": "relu"},
              ],
              independent=independent_normal,
          )
          for _ in range(ensemble_size)
      ]
      keras_ensemble = KerasEnsemble(networks)
  
      return keras_ensemble
  