<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_dict(self, d):
 """ Initialise an API message from a transmission-safe dictionary. """

        for key in d:
            if key == 'data':
                for dkey in d['data']:
                    if dkey in self._encode_fields:
                        setattr(self, str(dkey), base64.b64decode(d['data'][dkey]))
                    else:
                        setattr(self, str(dkey), d['data'][dkey])
            else:
                setattr(self, str(key), d[key])