# Path: deepcpg/models/utils.py
# class Model(object):
#     """Abstract model call.
# 
#     Abstract class of DNA, CpG, and Joint models.
# 
#     Parameters
#     ----------
#     dropout: float
#         Dropout rate.
#     l1_decay: float
#         L1 weight decay.
#     l2_decay: float
#         L2 weight decay.
#     init: str
#         Name of Keras initialization.
#     """
# 
#     def __init__(self, dropout=0.0, l1_decay=0.0, l2_decay=0.0,
#                  init='glorot_uniform'):
#         self.dropout = dropout
#         self.l1_decay = l1_decay
#         self.l2_decay = l2_decay
#         self.init = init
#         self.name = self.__class__.__name__
#         self.scope = None
# 
#     def inputs(self, *args, **kwargs):
#         """Return list of Keras model inputs."""
#         pass
# 
#     def _build(self, input, output):
#         """Build final model at the end of `__call__`."""
#         model = km.Model(input, output, name=self.name)
#         if self.scope:
#             for layer in model.layers:
#                 if not is_input_layer(layer):
#                     layer.name = '%s/%s' % (self.scope, layer.name)
#         return model
# 
#     def __call__(self, inputs=None):
#         """Build model.
# 
#         Parameters
#         ----------
#         inputs: list
#             Keras model inputs
#         """
#         pass
# 
# Path: deepcpg/utils.py
# def get_from_module(identifier, module_params, ignore_case=True):
#     """Return object from module.
# 
#     Return object with name `identifier` from module with items `module_params`.
# 
#     Parameters
#     ----------
#     identifier: str
#         Name of object, e.g. a function, in module.
#     module_params: dict
#         `dict` of items in module, e.g. `globals()`
#     ignore_case: bool
#         If `True`, ignore case of `identifier`.
# 
#     Returns
#     -------
#     object
#         Object with name `identifier` in module, e.g. a function or class.
#     """
#     if ignore_case:
#         _module_params = dict()
#         for key, value in six.iteritems(module_params):
#             _module_params[key.lower()] = value
#         _identifier = identifier.lower()
#     else:
#         _module_params = module_params
#         _identifier = identifier
#     item = _module_params.get(_identifier)
#     if not item:
#         raise ValueError('Invalid identifier "%s"!' % identifier)
#     return item


import inspect
from keras import layers as kl
from keras import regularizers as kr
from .utils import Model
from ..utils import get_from_module
        x = self._res_unit(x, [64, 64, 256], stage=2, block=1, stride=2)
        x = self._res_unit(x, [64, 64, 256], atrous=2, stage=2, block=2)
        x = self._res_unit(x, [64, 64, 256], atrous=4, stage=2, block=3)

        # 32
        x = self._res_unit(x, [128, 128, 512], stage=3, block=1, stride=2)
        x = self._res_unit(x, [128, 128, 512], atrous=2, stage=3, block=2)
        x = self._res_unit(x, [128, 128, 512], atrous=4, stage=3, block=3)

        # 16
        x = self._res_unit(x, [256, 256, 1024], stage=4, block=1, stride=2)

        x = kl.GlobalAveragePooling1D()(x)
        x = kl.Dropout(self.dropout)(x)

        return self._build(inputs, x)


def list_models():
    """Return the name of models in the module."""

    models = dict()
    for name, value in globals().items():
        if inspect.isclass(value) and name.lower().find('model') == -1:
            models[name] = value
    return models


def get(name):
    """Return object from module by its name."""

# Path: deepcpg/models/utils.py
# class Model(object):
#     """Abstract model call.
# 
#     Abstract class of DNA, CpG, and Joint models.
# 
#     Parameters
#     ----------
#     dropout: float
#         Dropout rate.
#     l1_decay: float
#         L1 weight decay.
#     l2_decay: float
#         L2 weight decay.
#     init: str
#         Name of Keras initialization.
#     """
# 
#     def __init__(self, dropout=0.0, l1_decay=0.0, l2_decay=0.0,
#                  init='glorot_uniform'):
#         self.dropout = dropout
#         self.l1_decay = l1_decay
#         self.l2_decay = l2_decay
#         self.init = init
#         self.name = self.__class__.__name__
#         self.scope = None
# 
#     def inputs(self, *args, **kwargs):
#         """Return list of Keras model inputs."""
#         pass
# 
#     def _build(self, input, output):
#         """Build final model at the end of `__call__`."""
#         model = km.Model(input, output, name=self.name)
#         if self.scope:
#             for layer in model.layers:
#                 if not is_input_layer(layer):
#                     layer.name = '%s/%s' % (self.scope, layer.name)
#         return model
# 
#     def __call__(self, inputs=None):
#         """Build model.
# 
#         Parameters
#         ----------
#         inputs: list
#             Keras model inputs
#         """
#         pass
# 
# Path: deepcpg/utils.py
# def get_from_module(identifier, module_params, ignore_case=True):
#     """Return object from module.
# 
#     Return object with name `identifier` from module with items `module_params`.
# 
#     Parameters
#     ----------
#     identifier: str
#         Name of object, e.g. a function, in module.
#     module_params: dict
#         `dict` of items in module, e.g. `globals()`
#     ignore_case: bool
#         If `True`, ignore case of `identifier`.
# 
#     Returns
#     -------
#     object
#         Object with name `identifier` in module, e.g. a function or class.
#     """
#     if ignore_case:
#         _module_params = dict()
#         for key, value in six.iteritems(module_params):
#             _module_params[key.lower()] = value
#         _identifier = identifier.lower()
#     else:
#         _module_params = module_params
#         _identifier = identifier
#     item = _module_params.get(_identifier)
#     if not item:
#         raise ValueError('Invalid identifier "%s"!' % identifier)
#     return item


# Path: deepcpg/models/dna.py
import inspect
from keras import layers as kl
from keras import regularizers as kr
from .utils import Model
from ..utils import get_from_module

        x = self._res_unit(x, [64, 64, 256], stage=2, block=1, stride=2)
        x = self._res_unit(x, [64, 64, 256], atrous=2, stage=2, block=2)
        x = self._res_unit(x, [64, 64, 256], atrous=4, stage=2, block=3)

        # 32
        x = self._res_unit(x, [128, 128, 512], stage=3, block=1, stride=2)
        x = self._res_unit(x, [128, 128, 512], atrous=2, stage=3, block=2)
        x = self._res_unit(x, [128, 128, 512], atrous=4, stage=3, block=3)

        # 16
        x = self._res_unit(x, [256, 256, 1024], stage=4, block=1, stride=2)

        x = kl.GlobalAveragePooling1D()(x)
        x = kl.Dropout(self.dropout)(x)

        return self._build(inputs, x)


def list_models():
    """Return the name of models in the module."""

    models = dict()
    for name, value in globals().items():
        if inspect.isclass(value) and name.lower().find('model') == -1:
            models[name] = value
    return models


def get(name):
    """Return object from module by its name."""

    return get_from_module(name, globals())