def _ModifiedEncoder(wire_type, encode_value, compute_value_size, modify_value):
def SpecificEncoder(field_number, is_repeated, is_packed):<EOL><INDENT>if is_packed:<EOL><INDENT>tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)<EOL>local_EncodeVarint = _EncodeVarint<EOL>def EncodePackedField(write, value):<EOL><INDENT>write(tag_bytes)<EOL>size = <NUM_LIT:0><EOL>for element in value:<EOL><INDENT>size += compute_value_size(modify_value(element))<EOL><DEDENT>local_EncodeVarint(write, size)<EOL>for element in value:<EOL><INDENT>encode_value(write, modify_value(element))<EOL><DEDENT><DEDENT>return EncodePackedField<EOL><DEDENT>elif is_repeated:<EOL><INDENT>tag_bytes = TagBytes(field_number, wire_type)<EOL>def EncodeRepeatedField(write, value):<EOL><INDENT>for element in value:<EOL><INDENT>write(tag_bytes)<EOL>encode_value(write, modify_value(element))<EOL><DEDENT><DEDENT>return EncodeRepeatedField<EOL><DEDENT>else:<EOL><INDENT>tag_bytes = TagBytes(field_number, wire_type)<EOL>def EncodeField(write, value):<EOL><INDENT>write(tag_bytes)<EOL>return encode_value(write, modify_value(value))<EOL><DEDENT>return EncodeField<EOL><DEDENT><DEDENT>return SpecificEncoder<EOL>
Like SimpleEncoder but additionally invokes modify_value on every value
    before passing it to encode_value.  Usually modify_value is ZigZagEncode.