import typing
import torch


def initialize_parameters(config: dict) -> typing.Tuple[torch.Tensor, torch.distributions.MultivariateNormal]:
    """Initialize alpha and the parameters of normal-Wishart distribution

    Args:
        config: a dictionary containing the configuration

    Returns:
        alpha: an L-by-K matrix
        gmm: K D-variate Gaussian components
    """
    print('Initialize parameters...')
    # INITIALIZATION - document-invariant parameters
    alpha = config['alpha0'] + 0.1 * torch.rand(size=(config['L'], config['K']), dtype=torch.float, device=config['device'])

    # initialize Gaussian components
    gmm = torch.distributions.multivariate_normal.MultivariateNormal(
        loc=0.05 * torch.randn(size=(config['K'], config['D']), device=config['device']),
        scale_tril=10 * torch.diag_embed(input=torch.ones(size=(config['K'], config['D']), device=config['device']))
    )

    return alpha, gmm