'Construct modalities in problem_hparams.'

def _create_modalities(self, problem_hparams, hparams):

    input_modality_overrides = {}
    for override_str in hparams.input_modalities.split(';'):
        if (override_str != 'default'):
            parts = override_str.split(':')
            feature_name = parts[0]
            modality_name = ':'.join(parts[1:])
            input_modality_overrides[feature_name] = modality_name
    target_modality_name = None
    if (hparams.target_modality and (hparams.target_modality != 'default')):
        target_modality_name = hparams.target_modality
    input_modality = {}
    for (f, modality_spec) in six.iteritems(problem_hparams.input_modality):
        if (f in input_modality_overrides):
            _warn_changed_modality_type(input_modality_overrides[f], modality_spec[0], f)
            modality_spec = (input_modality_overrides[f], modality_spec[1])
        input_modality[f] = registry.create_modality(modality_spec, hparams)
    problem_hparams.input_modality = input_modality
    target_modality_spec = problem_hparams.target_modality
    if target_modality_name:
        _warn_changed_modality_type(target_modality_name, target_modality_spec[0], 'target')
        target_modality_spec = (target_modality_name, target_modality_spec[1])
    target_modality = registry.create_modality(target_modality_spec, hparams)
    problem_hparams.target_modality = target_modality
