code: def _generate_enumerated_subtypes_tag_mapping(self, ns, data_type):
          
          assert data_type.has_enumerated_subtypes()
  
          # Generate _tag_to_subtype_ attribute: Map from string type tag to
          # the validator of the referenced subtype. Used on deserialization
          # to look up the subtype for a given tag.
          tag_to_subtype_items = []
          for tags, subtype in data_type.get_all_subtypes_with_tags():
              tag_to_subtype_items.append("{}: {}".format(
                  tags,
                  generate_validator_constructor(ns, subtype)))
  
          self.generate_multiline_list(
              tag_to_subtype_items,
              before='{}._tag_to_subtype_ = '.format(data_type.name),
              delim=('{', '}'),
              compact=False)
  
          # Generate _pytype_to_tag_and_subtype_: Map from Python class to a
          # tuple of (type tag, subtype). Used on serialization to lookup how a
          # class should be encoded based on the root struct's enumerated
          # subtypes.
          items = []
          for tag, subtype in data_type.get_all_subtypes_with_tags():
              items.append("{0}: ({1}, {2})".format(
                  fmt_class(subtype.name),
                  tag,
                  generate_validator_constructor(ns, subtype)))
          self.generate_multiline_list(
              items,
              before='{}._pytype_to_tag_and_subtype_ = '.format(data_type.name),
              delim=('{', '}'),
              compact=False)
  
          # Generate _is_catch_all_ attribute:
          self.emit('{}._is_catch_all_ = {!r}'.format(
              data_type.name, data_type.is_catch_all()))
  
          self.emit()
docs: Generates attributes needed for serializing and deserializing structs
          with enumerated subtypes. These assignments are made after all the
          Python class definitions to ensure that all references exist.