import tensorflow as tf

    class InputOnlyProblem(problem_module.Problem):

      def hparams(self, defaults, model_hparams):
        hp = defaults
        hp.modality = {"inputs": modalities.SymbolModality}
        hp.vocab_size = {"inputs": 2}

    problem = InputOnlyProblem(False, False)
    p_hparams = problem.get_hparams()
    self.assertIsInstance(p_hparams.modality["inputs"],
                          modalities.SymbolModality)
    self.assertLen(p_hparams.modality, 1)

  @tf.contrib.eager.run_test_in_graph_and_eager_modes()
  def testProblemHparamsTargetOnlyModality(self):
    class TargetOnlyProblem(problem_module.Problem):

      def hparams(self, defaults, model_hparams):
        hp = defaults
        hp.modality = {"targets": modalities.SymbolModality}
        hp.vocab_size = {"targets": 3}

    problem = TargetOnlyProblem(False, False)
    p_hparams = problem.get_hparams()
    self.assertIsInstance(p_hparams.modality["targets"],
                          modalities.SymbolModality)
