from typing import Dict
from typing import Any
from typing import Tuple
from typing import Optional


def calculate_input_shapes(
        settings: Dict[str, Any]
) -> Tuple[Tuple[Optional[int], ...], Tuple[Optional[int], ...]]:
    """
    Calculate shapes of inputs based on settings of experiment.

    :param settings:
        configuration of an experiment
    :return:
        shapes of discriminator input and generator input
    """
    data_shape = settings['data']['shape']
    n_channels = data_shape[0]
    internal_size = settings['discriminator']['setup']['internal_size']
    frame_size = settings['discriminator']['setup']['frame_size']
    fragment_size = internal_size + 2 * frame_size
    d_input_shape = (None, fragment_size, fragment_size, n_channels)
    g_input_shape = (None, settings['generator']['setup']['z_dim'])
    return d_input_shape, g_input_shape