def test_translation_variable_languages_nolist(self):
   self.assertFeature(
       feature=features.TranslationVariableLanguages(),
       shape={"language": (None,), "translation": (None,)},
       dtype={"language": tf.string, "translation": tf.string},
       tests=[
           testing.FeatureExpectationItem(
               value={"en": EN_HELLO, "zh": ZH_HELLO},
               expected={"language": [EN_B, ZH_B],
                         "translation": [tf.compat.as_bytes(EN_HELLO),
                                         tf.compat.as_bytes(ZH_HELLO)]}
           ),
           testing.FeatureExpectationItem(
               value={"fr": FR_HELLO, "de": DE_HELLO, "zh": ZH_HELLO},
               expected={"language": [DE_B, FR_B, ZH_B],
                         "translation": [tf.compat.as_bytes(DE_HELLO),
                                         tf.compat.as_bytes(FR_HELLO),
                                         tf.compat.as_bytes(ZH_HELLO)]}
           ),
           testing.FeatureExpectationItem(
               value={"fr": [FR_HELLO, FR_HELLO[0:-1]],
                      "en": EN_HELLO},
               expected={"language": [EN_B, FR_B, FR_B],
                         "translation": [tf.compat.as_bytes(EN_HELLO),
                                         tf.compat.as_bytes(FR_HELLO[0:-1]),
                                         tf.compat.as_bytes(FR_HELLO)]}
           ),
       ],
   )
 def test_translation_variable_languages_list(self):
   self.assertFeature(
       feature=features.TranslationVariableLanguages(
           languages=["en", "de", "zh"]),
       shape={"language": (None,), "translation": (None,)},
       dtype={"language": tf.string, "translation": tf.string},
       tests=[
           testing.FeatureExpectationItem(
               value={"en": EN_HELLO, "zh": ZH_HELLO},
               expected={"language": [EN_B, ZH_B],
                         "translation": [tf.compat.as_bytes(EN_HELLO),
                                         tf.compat.as_bytes(ZH_HELLO)]}
           ),
           testing.FeatureExpectationItem(
               value={"fr": FR_HELLO, "de": DE_HELLO, "zh": ZH_HELLO},
               raise_cls=ValueError,
               raise_msg="Some languages in example (fr) are not in valid set "
                         "(de, en, zh)",
           ),
       ],
   )