'Create a T2TModel.
Args:
hparams: a hyperparameters object.
mode: The execution mode, as defined in tf.contrib.learn.ModeKeys.
problem_hparams: a hyperparameters object.
problem_idx: an integer.
data_parallelism: a expert_utils.parallelism
(specifies devices for data parallelism).
ps_devices: a list of devices to be used for experts
Returns:
a T2TModel'

def __init__(self, hparams, mode, problem_hparams, problem_idx=0, data_parallelism=None, ps_devices=None):

    if (data_parallelism is None):
        data_parallelism = eu.Parallelism([''])
    if (ps_devices is None):
        ps_devices = ['']
    hparams = copy.copy(hparams)
    hparams.add_hparam('mode', mode)
    if (mode != tf.contrib.learn.ModeKeys.TRAIN):
        for key in hparams.values():
            if (key[(- len('dropout')):] == 'dropout'):
                setattr(hparams, key, 0.0)
    if hparams.shared_embedding_and_softmax_weights:
        same_vocab_sizes = True
        for problem in hparams.problems:
            if ('inputs' in problem.input_modality):
                if (problem.input_modality['inputs'] != problem.target_modality):
                    same_vocab_sizes = False
        if (not same_vocab_sizes):
            tf.logging.info('Unsetting    shared_embedding_and_softmax_weights.')
            hparams.shared_embedding_and_softmax_weights = 0
    self._hparams = hparams
    self._data_parallelism = data_parallelism
    self._num_datashards = data_parallelism.n
    self._ps_devices = ps_devices
    self._problem_hparams = problem_hparams
    self._problem_idx = problem_idx
    self._create_modalities(problem_hparams, hparams)
