# Path: minos/model/parameters.py
# def is_custom_activation(name):
#     return name in custom_activations
# 
# def get_custom_activation(name):
#     return custom_activations.get(name, None)
# 
# def is_custom_layer(name):
#     return name in custom_layers
# 
# def get_custom_layer(name):
#     return custom_layers.get(name, None)
# 
# Path: minos/tf_utils.py
# def get_logical_device(physical_device):
#     if is_gpu_device(physical_device):
#         return '/gpu:0'
#     return physical_device
# 
# def cpu_device():
#     return '/cpu:0'


from copy import deepcopy
from keras.engine.topology import Input, Merge, merge
from keras.engine.training import Model
from keras.layers.core import Dense, Lambda
from keras.regularizers import L1L2Regularizer
from minos.model.parameters import is_custom_activation, get_custom_activation,\
    is_custom_layer, get_custom_layer
from minos.tf_utils import get_logical_device, cpu_device
import logging
import traceback
import keras
    import tensorflow as tf
    import tensorflow as tf
    if isinstance(inputs, list) and len(inputs) == 1:
        inputs = inputs[0]
    if block.input_layers and len(block.input_layers) > 0:
        for layer in block.input_layers:
            inputs = _build_layer_model(inputs, layer)
    for layer in block.layers:
        inputs = _build_layer_model(inputs, layer)
    return inputs


def _maybe_merge_inputs(inputs):
    if isinstance(inputs, list) and len(inputs) > 1:
        return Merge(mode='concat')(inputs)
    elif isinstance(inputs, list) and len(inputs) == 1:
        return inputs[0]
    else:
        return inputs


def _build_layer_model(inputs, layer):
    try:
        parameters = _build_layer_parameters(layer)
        model = _get_layer_model(layer.layer_type)
        return model(**parameters)(inputs)
    except Exception as ex:
        logging.debug(traceback.format_exc())
        raise ex


def _get_layer_model(layer_type):

# Path: minos/model/parameters.py
# def is_custom_activation(name):
#     return name in custom_activations
# 
# def get_custom_activation(name):
#     return custom_activations.get(name, None)
# 
# def is_custom_layer(name):
#     return name in custom_layers
# 
# def get_custom_layer(name):
#     return custom_layers.get(name, None)
# 
# Path: minos/tf_utils.py
# def get_logical_device(physical_device):
#     if is_gpu_device(physical_device):
#         return '/gpu:0'
#     return physical_device
# 
# def cpu_device():
#     return '/cpu:0'


# Path: minos/model/build.py
from copy import deepcopy
from keras.engine.topology import Input, Merge, merge
from keras.engine.training import Model
from keras.layers.core import Dense, Lambda
from keras.regularizers import L1L2Regularizer
from minos.model.parameters import is_custom_activation, get_custom_activation,\
    is_custom_layer, get_custom_layer
from minos.tf_utils import get_logical_device, cpu_device
import logging
import traceback
import keras
    import tensorflow as tf
    import tensorflow as tf

    if isinstance(inputs, list) and len(inputs) == 1:
        inputs = inputs[0]
    if block.input_layers and len(block.input_layers) > 0:
        for layer in block.input_layers:
            inputs = _build_layer_model(inputs, layer)
    for layer in block.layers:
        inputs = _build_layer_model(inputs, layer)
    return inputs


def _maybe_merge_inputs(inputs):
    if isinstance(inputs, list) and len(inputs) > 1:
        return Merge(mode='concat')(inputs)
    elif isinstance(inputs, list) and len(inputs) == 1:
        return inputs[0]
    else:
        return inputs


def _build_layer_model(inputs, layer):
    try:
        parameters = _build_layer_parameters(layer)
        model = _get_layer_model(layer.layer_type)
        return model(**parameters)(inputs)
    except Exception as ex:
        logging.debug(traceback.format_exc())
        raise ex


def _get_layer_model(layer_type):

    if is_custom_layer(layer_type):