def encode(data, json_dumps=default_json_dumps):
payload = '<STR_LIT>'<EOL>msg = str(MSG_TYPES[data['<STR_LIT:type>']])<EOL>if msg in ['<STR_LIT:0>', '<STR_LIT:1>']:<EOL><INDENT>msg += '<STR_LIT>' + data['<STR_LIT>']<EOL>if '<STR_LIT>' in data and data['<STR_LIT>'] != '<STR_LIT>':<EOL><INDENT>msg += '<STR_LIT::>' + data['<STR_LIT>']<EOL><DEDENT><DEDENT>elif msg == '<STR_LIT:2>':<EOL><INDENT>msg += '<STR_LIT>'<EOL><DEDENT>elif msg in ['<STR_LIT:3>', '<STR_LIT:4>', '<STR_LIT:5>']:<EOL><INDENT>if msg == '<STR_LIT:3>':<EOL><INDENT>payload = data['<STR_LIT:data>']<EOL><DEDENT>if msg == '<STR_LIT:4>':<EOL><INDENT>payload = json_dumps(data['<STR_LIT:data>'])<EOL><DEDENT>if msg == '<STR_LIT:5>':<EOL><INDENT>d = {}<EOL>d['<STR_LIT:name>'] = data['<STR_LIT:name>']<EOL>if '<STR_LIT:args>' in data and data['<STR_LIT:args>'] != []:<EOL><INDENT>d['<STR_LIT:args>'] = data['<STR_LIT:args>']<EOL><DEDENT>payload = json_dumps(d)<EOL><DEDENT>if '<STR_LIT:id>' in data:<EOL><INDENT>msg += '<STR_LIT::>' + str(data['<STR_LIT:id>'])<EOL>if data['<STR_LIT>'] == '<STR_LIT:data>':<EOL><INDENT>msg += '<STR_LIT:+>'<EOL><DEDENT>msg += '<STR_LIT::>'<EOL><DEDENT>else:<EOL><INDENT>msg += '<STR_LIT>'<EOL><DEDENT>if '<STR_LIT>' not in data:<EOL><INDENT>data['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>if payload != '<STR_LIT>':<EOL><INDENT>msg += data['<STR_LIT>'] + '<STR_LIT::>' + payload<EOL><DEDENT>else:<EOL><INDENT>msg += data['<STR_LIT>']<EOL><DEDENT><DEDENT>elif msg == '<STR_LIT>':<EOL><INDENT>msg += '<STR_LIT>' + data.get('<STR_LIT>', '<STR_LIT>') + '<STR_LIT::>' + str(data['<STR_LIT>'])<EOL>if '<STR_LIT:args>' in data and data['<STR_LIT:args>'] != []:<EOL><INDENT>msg += '<STR_LIT:+>' + json_dumps(data['<STR_LIT:args>'])<EOL><DEDENT><DEDENT>elif msg == '<STR_LIT>':<EOL><INDENT>msg += '<STR_LIT>'<EOL>if '<STR_LIT>' in data and data['<STR_LIT>'] != '<STR_LIT>':<EOL><INDENT>msg += str(ERROR_REASONS[data['<STR_LIT>']])<EOL><DEDENT>if '<STR_LIT>' in data and data['<STR_LIT>'] != '<STR_LIT>':<EOL><INDENT>msg += '<STR_LIT:+>' + str(ERROR_ADVICES[data['<STR_LIT>']])<EOL><DEDENT>msg += data['<STR_LIT>']<EOL><DEDENT>elif msg == '<STR_LIT>':<EOL><INDENT>msg += '<STR_LIT>'<EOL><DEDENT>return msg<EOL>
Encode an attribute dict into a byte string.