# Path: amdtk/io/persistent_model.py
# class PersistentModel(metaclass=abc.ABCMeta):
#     """Base class for classes that can be serialized."""
# 
#     @abc.abstractmethod
#     def to_dict(self):
#         """Get the data of the model into a dictionary.
# 
#         Returns
#         -------
#         dict : dictionary
#             Dictionary containing the model's data.
# 
#         """
#         pass
# 
#     @abc.abstractclassmethod
#     def load_from_dict(cls, model_data):
#         """Create and initialize the model from a dictionary.
# 
#         Parameters
#         ----------
#         model_data : dictionary
#             Dictionary containing the model's data.
# 
#         Returns
#         -------
#         model : :class:`PersistentModel`
#             Model initialized from the data.
# 
#         """
#         pass
# 
#     def save(self, fname):
#         """Store the model.
# 
#         Parameters
#         ----------
#         fname : string
#             String where to store the model.
# 
#         """
#         retval = self.to_dict()
#         retval['class'] = self.__class__
#         with open(fname, 'wb') as fid:
#             pickle.dump(retval, fid)
# 
#     @staticmethod
#     def load(file_obj):
#         """Load a model.
# 
#         Parameters
#         ----------
#         file_obj : file object
#             File-like object  where to store the model.
# 
#         Returns
#         -------
#         model : :class:`PersistentModel`
#             Model initialized from the stored data.
# 
#         """
#         model_data = pickle.load(file_obj)
#         cls = model_data['class']
#         return cls.load_from_dict(model_data)
# 
# Path: amdtk/io/features_loader.py
# class FeaturesPreprocessor(metaclass=abc.ABCMeta):
# 
#     @abc.abstractproperty
#     def description(self):
#         """Readable name for logging."""
#         pass
# 
#     def process(self, fname, fea_data):
#         """Process the features.
# 
#         Parameters
#         ----------
#         fname : string
#             Path to the file to load.
# 
#         fea_data : dictionary
#             Dictionary containing the various value relative to the
#             features. The actual pairs key, value of the dictionary
#             will depends on the preprocessors called before.
# 
#         Returns
#         -------
#         fea_data : dictionary
#             The previous `fea_data` with the new data extracted from
#             current preprocessor.
# 
#         """
#         pass


import abc
import numpy as np
        import pdb
from ..io.persistent_model import PersistentModel
from ..io.features_loader import FeaturesPreprocessor
    """Wrapper of a list of accumulated sufficient statistics."""

    def __init__(self, stats):
        """Initialize the list of stats.

        Parameters
        ----------
        stats : list
            List of numpy.ndarray.

        """
        self._stats = stats

    def __setitem__(self, k, value):
        self._stats[k] = value

    def __getitem__(self, k):
        return self._stats[k]

    def __iadd__(self, stats):
        for i in range(len(self._stats)):
            self._stats[i] += stats[i]
        return self

    def __imul__(self, scale):
        for i in range(len(self._stats)):
            self._stats[i] *= scale
        return self



# Path: amdtk/io/persistent_model.py
# class PersistentModel(metaclass=abc.ABCMeta):
#     """Base class for classes that can be serialized."""
# 
#     @abc.abstractmethod
#     def to_dict(self):
#         """Get the data of the model into a dictionary.
# 
#         Returns
#         -------
#         dict : dictionary
#             Dictionary containing the model's data.
# 
#         """
#         pass
# 
#     @abc.abstractclassmethod
#     def load_from_dict(cls, model_data):
#         """Create and initialize the model from a dictionary.
# 
#         Parameters
#         ----------
#         model_data : dictionary
#             Dictionary containing the model's data.
# 
#         Returns
#         -------
#         model : :class:`PersistentModel`
#             Model initialized from the data.
# 
#         """
#         pass
# 
#     def save(self, fname):
#         """Store the model.
# 
#         Parameters
#         ----------
#         fname : string
#             String where to store the model.
# 
#         """
#         retval = self.to_dict()
#         retval['class'] = self.__class__
#         with open(fname, 'wb') as fid:
#             pickle.dump(retval, fid)
# 
#     @staticmethod
#     def load(file_obj):
#         """Load a model.
# 
#         Parameters
#         ----------
#         file_obj : file object
#             File-like object  where to store the model.
# 
#         Returns
#         -------
#         model : :class:`PersistentModel`
#             Model initialized from the stored data.
# 
#         """
#         model_data = pickle.load(file_obj)
#         cls = model_data['class']
#         return cls.load_from_dict(model_data)
# 
# Path: amdtk/io/features_loader.py
# class FeaturesPreprocessor(metaclass=abc.ABCMeta):
# 
#     @abc.abstractproperty
#     def description(self):
#         """Readable name for logging."""
#         pass
# 
#     def process(self, fname, fea_data):
#         """Process the features.
# 
#         Parameters
#         ----------
#         fname : string
#             Path to the file to load.
# 
#         fea_data : dictionary
#             Dictionary containing the various value relative to the
#             features. The actual pairs key, value of the dictionary
#             will depends on the preprocessors called before.
# 
#         Returns
#         -------
#         fea_data : dictionary
#             The previous `fea_data` with the new data extracted from
#             current preprocessor.
# 
#         """
#         pass


# Path: amdtk/models/model.py
import abc
import numpy as np
        import pdb
from ..io.persistent_model import PersistentModel
from ..io.features_loader import FeaturesPreprocessor

    """Wrapper of a list of accumulated sufficient statistics."""

    def __init__(self, stats):
        """Initialize the list of stats.

        Parameters
        ----------
        stats : list
            List of numpy.ndarray.

        """
        self._stats = stats

    def __setitem__(self, k, value):
        self._stats[k] = value

    def __getitem__(self, k):
        return self._stats[k]

    def __iadd__(self, stats):
        for i in range(len(self._stats)):
            self._stats[i] += stats[i]
        return self

    def __imul__(self, scale):
        for i in range(len(self._stats)):
            self._stats[i] *= scale
        return self



class DiscreteLatentModel(PersistentModel, metaclass=abc.ABCMeta):