<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def account_update_credentials(self, display_name=None, note=None, avatar=None, avatar_mime_type=None, header=None, header_mime_type=None, locked=None, fields=None):
 """ Update the profile for the currently logged-in user. 'note' is the user's bio. 'avatar' and 'header' are images. As with media uploads, it is possible to either pass image data and a mime type, or a filename of an image file, for either. 'locked' specifies whether the user needs to manually approve follow requests. 'fields' can be a list of up to four name-value pairs (specified as tuples) to appear as semi-structured information in the users profile. Returns the updated `user dict` of the logged-in user. """

        params_initial = collections.OrderedDict(locals())
        
        # Load avatar, if specified
        if not avatar is None:
            if avatar_mime_type is None and (isinstance(avatar, str) and os.path.isfile(avatar)):
                avatar_mime_type = guess_type(avatar)
                avatar = open(avatar, 'rb')

            if avatar_mime_type is None:
                raise MastodonIllegalArgumentError('Could not determine mime type or data passed directly without mime type.')
        
        # Load header, if specified
        if not header is None:
            if header_mime_type is None and (isinstance(avatar, str) and os.path.isfile(header)):
                header_mime_type = guess_type(header)
                header = open(header, 'rb')

            if header_mime_type is None:
                raise MastodonIllegalArgumentError('Could not determine mime type or data passed directly without mime type.')
        
        # Convert fields
        if fields != None:
            if len(fields) > 4:
                raise MastodonIllegalArgumentError('A maximum of four fields are allowed.')
            
            fields_attributes = []
            for idx, (field_name, field_value) in enumerate(fields):
                params_initial['fields_attributes[' + str(idx) + '][name]'] = field_name
                params_initial['fields_attributes[' + str(idx) + '][value]'] = field_value
            
        # Clean up params
        for param in ["avatar", "avatar_mime_type", "header", "header_mime_type", "fields"]:
            if param in params_initial:
                del params_initial[param]
        
        # Create file info
        files = {}
        if not avatar is None:
            avatar_file_name = "mastodonpyupload_" + mimetypes.guess_extension(avatar_mime_type)
            files["avatar"] = (avatar_file_name, avatar, avatar_mime_type)
        if not header is None:
            header_file_name = "mastodonpyupload_" + mimetypes.guess_extension(header_mime_type)
            files["header"] = (header_file_name, header, header_mime_type)
        
        params = self.__generate_params(params_initial)
        return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params, files=files)