# Path: ehr_prediction_modeling/types.py
# class ForwardFunctionReturns(
#     collections.namedtuple(
#         "ForwardFunctionReturns",
#         ["model_output", "hidden_states", "inputs", "activations"],
#     )):
# class EmbeddingType(object):
# class EmbeddingEncoderType(object):
# class ActivationFunction(object):
# class RegularizationType(object):
# class TaskType(object):
# class BestModelMetric(object):
# class TaskNames(object):
# class TaskTypes(object):
# class TaskLossType(object):
# class RNNCellType(object):
# class FeatureTypes(object):
# class Optimizers(object):
# class LearningRateScheduling(object):
# class EmbeddingCombinationMethod(object):
# class SNRBlockConnType(object):
# class SubNettoSubNetConnType(object):
# class SNRInputCombinationType(object):
# class LossCombinationType(object):
# class ModelTypes(object):
# class TaskLayerTypes(object):
# class ModelMode(object):
#   LOOKUP = "Lookup"
#   DEEP_EMBEDDING = "DeepEmbedding"
#   RESIDUAL = "residual"
#   FC = "fc"
#   SNR = "snr"
#   TANH = "tanh"
#   RELU = "relu"
#   LRELU = "lrelu"
#   SWISH = "swish"
#   ELU = "elu"
#   SLU = "selu"
#   ELISH = "elish"
#   HARD_ELISH = "hard_elish"
#   SIGMOID = "sigmoid"
#   HARD_SIGMOID = "hard_sigmoid"
#   TANH_PEN = "tanh_pen"
#   NONE = "None"
#   L1 = "L1"
#   L2 = "L2"
#   BINARY_CLASSIFICATION = "BinaryClassification"
#   REGRESSION = "Regression"
#   PRAUC = "prauc"
#   ROCAUC = "rocauc"
#   L1 = "l1"
#   ADVERSE_OUTCOME_RISK = "AdverseOutcomeRisk"
#   LAB_REGRESSION = "Labs"
#   BINARIZED_LOS = "BinarizedLengthOfStay"
#   REGRESSION_LOS = "RegressionLengthOfStay"
#   MORTALITY = "MortalityRisk"
#   READMISSION = "ReadmissionRisk"
#   ADVERSE_OUTCOME_RISK = "ao_risk"
#   LAB_REGRESSION = "labs_regression"
#   LOS = "length_of_stay"
#   MORTALITY = "mortality"
#   READMISSION = "readmission"
#   CE = "CE"
#   MULTI_CE = "MULTI_CE"
#   BRIER = "Brier"
#   L1 = "L1"
#   L2 = "L2"
#   SRU = "SRU"
#   LSTM = "LSTM"
#   UGRNN = "UGRNN"
#   PRESENCE_SEQ = "pres_s"  # Sequential presence features
#   NUMERIC_SEQ = "num_s"  # Sequential numerical features
#   CATEGORY_COUNTS_SEQ = "count_s"  # Sequential category counts features
# FEAT_TO_NAME = {
#     "pres_s": "presence",
#     "num_s": "numeric",
#     "count_s": "category_counts",
# }
#   SGD = "SGD"
#   ADAM = "Adam"
#   RMSPROP = "RMSprop"
#   FIXED = "fixed"
#   EXPONENTIAL_DECAY = "exponential_decay"
#   CONCATENATE = "concatenate"
#   SUM_ALL = "sum_all"
#   SUM_BY_SUFFIX = "sum_by_suffix"
#   COMBINE_SNR_OUT = "combine_snr_out"
#   FC = "fc"
#   HIGHWAY = "highway"
#   RESIDUAL = "residual"
#   NONE = "None"
#   BOOL = "bool"
#   SCALAR_WEIGHT = "scalar_weight"
#   CONCATENATE = "concatenate"
#   SUM_ALL = "sum"
#   SUM_ALL = "SUM_ALL"
#   UNCERTAINTY_WEIGHTED = "UNCERTAINTY_WEIGHTED"
#   RNN = "RNN"
#   SNRNN = "SNRNN"
#   NONE = "none"
#   MLP = "MLP"
#   SNRMLP = "SNRMLP"
#   TRAIN = "train"
#   EVAL = "eval"
#   PREDICT = "predict"
#   def is_train(cls, mode: str) -> bool:


import abc
import collections
import typing
import tensorflow.compat.v1 as tf
from typing import Any, Dict, List, Optional, Tuple
from ehr_prediction_modeling import types
  from ehr_prediction_modeling import configdict

# Lint as: python3
"""Base class for EHR embeddings."""



if typing.TYPE_CHECKING:


class InputEmbeddingBase(metaclass=abc.ABCMeta):
  """The base embedding class declaring the interface."""

  def __init__(self,
               encoder_config: "configdict.ConfigDict",
               emb_dim_dict: Dict[str, int],
               has_embedding_loss: Optional[bool] = False):
    """Initialize the embedding base object.

    Args:
      encoder_config: ConfigDict of encoder parameters.
      emb_dim_dict: Dict of feature name to dimension of the embedding for that
        feature.
      has_embedding_loss: True if this embedding has a loss.
    """
    self._config = encoder_config
    # Regularization depends on this
    self._name = self._config.embedding_type
    self._embed_dim_dict = emb_dim_dict
    # Boolean, whether in training mode to apply dropout / batch normalization.
    self._is_training = types.ModelMode.is_train(

# Path: ehr_prediction_modeling/types.py
# class ForwardFunctionReturns(
#     collections.namedtuple(
#         "ForwardFunctionReturns",
#         ["model_output", "hidden_states", "inputs", "activations"],
#     )):
# class EmbeddingType(object):
# class EmbeddingEncoderType(object):
# class ActivationFunction(object):
# class RegularizationType(object):
# class TaskType(object):
# class BestModelMetric(object):
# class TaskNames(object):
# class TaskTypes(object):
# class TaskLossType(object):
# class RNNCellType(object):
# class FeatureTypes(object):
# class Optimizers(object):
# class LearningRateScheduling(object):
# class EmbeddingCombinationMethod(object):
# class SNRBlockConnType(object):
# class SubNettoSubNetConnType(object):
# class SNRInputCombinationType(object):
# class LossCombinationType(object):
# class ModelTypes(object):
# class TaskLayerTypes(object):
# class ModelMode(object):
#   LOOKUP = "Lookup"
#   DEEP_EMBEDDING = "DeepEmbedding"
#   RESIDUAL = "residual"
#   FC = "fc"
#   SNR = "snr"
#   TANH = "tanh"
#   RELU = "relu"
#   LRELU = "lrelu"
#   SWISH = "swish"
#   ELU = "elu"
#   SLU = "selu"
#   ELISH = "elish"
#   HARD_ELISH = "hard_elish"
#   SIGMOID = "sigmoid"
#   HARD_SIGMOID = "hard_sigmoid"
#   TANH_PEN = "tanh_pen"
#   NONE = "None"
#   L1 = "L1"
#   L2 = "L2"
#   BINARY_CLASSIFICATION = "BinaryClassification"
#   REGRESSION = "Regression"
#   PRAUC = "prauc"
#   ROCAUC = "rocauc"
#   L1 = "l1"
#   ADVERSE_OUTCOME_RISK = "AdverseOutcomeRisk"
#   LAB_REGRESSION = "Labs"
#   BINARIZED_LOS = "BinarizedLengthOfStay"
#   REGRESSION_LOS = "RegressionLengthOfStay"
#   MORTALITY = "MortalityRisk"
#   READMISSION = "ReadmissionRisk"
#   ADVERSE_OUTCOME_RISK = "ao_risk"
#   LAB_REGRESSION = "labs_regression"
#   LOS = "length_of_stay"
#   MORTALITY = "mortality"
#   READMISSION = "readmission"
#   CE = "CE"
#   MULTI_CE = "MULTI_CE"
#   BRIER = "Brier"
#   L1 = "L1"
#   L2 = "L2"
#   SRU = "SRU"
#   LSTM = "LSTM"
#   UGRNN = "UGRNN"
#   PRESENCE_SEQ = "pres_s"  # Sequential presence features
#   NUMERIC_SEQ = "num_s"  # Sequential numerical features
#   CATEGORY_COUNTS_SEQ = "count_s"  # Sequential category counts features
# FEAT_TO_NAME = {
#     "pres_s": "presence",
#     "num_s": "numeric",
#     "count_s": "category_counts",
# }
#   SGD = "SGD"
#   ADAM = "Adam"
#   RMSPROP = "RMSprop"
#   FIXED = "fixed"
#   EXPONENTIAL_DECAY = "exponential_decay"
#   CONCATENATE = "concatenate"
#   SUM_ALL = "sum_all"
#   SUM_BY_SUFFIX = "sum_by_suffix"
#   COMBINE_SNR_OUT = "combine_snr_out"
#   FC = "fc"
#   HIGHWAY = "highway"
#   RESIDUAL = "residual"
#   NONE = "None"
#   BOOL = "bool"
#   SCALAR_WEIGHT = "scalar_weight"
#   CONCATENATE = "concatenate"
#   SUM_ALL = "sum"
#   SUM_ALL = "SUM_ALL"
#   UNCERTAINTY_WEIGHTED = "UNCERTAINTY_WEIGHTED"
#   RNN = "RNN"
#   SNRNN = "SNRNN"
#   NONE = "none"
#   MLP = "MLP"
#   SNRMLP = "SNRMLP"
#   TRAIN = "train"
#   EVAL = "eval"
#   PREDICT = "predict"
#   def is_train(cls, mode: str) -> bool:


# Path: ehr_prediction_modeling/embeddings/input_embedding_base.py
import abc
import collections
import typing
import tensorflow.compat.v1 as tf
from typing import Any, Dict, List, Optional, Tuple
from ehr_prediction_modeling import types
  from ehr_prediction_modeling import configdict


# Lint as: python3
"""Base class for EHR embeddings."""



if typing.TYPE_CHECKING:


class InputEmbeddingBase(metaclass=abc.ABCMeta):
  """The base embedding class declaring the interface."""

  def __init__(self,
               encoder_config: "configdict.ConfigDict",
               emb_dim_dict: Dict[str, int],
               has_embedding_loss: Optional[bool] = False):
    """Initialize the embedding base object.

    Args:
      encoder_config: ConfigDict of encoder parameters.
      emb_dim_dict: Dict of feature name to dimension of the embedding for that
        feature.
      has_embedding_loss: True if this embedding has a loss.
    """
    self._config = encoder_config
    # Regularization depends on this
    self._name = self._config.embedding_type
    self._embed_dim_dict = emb_dim_dict
    # Boolean, whether in training mode to apply dropout / batch normalization.
    self._is_training = types.ModelMode.is_train(

        self._config.get("mode", types.ModelMode.TRAIN))