def METHOD_NAME(client, resource_group_name, account_name, system_assigned=False, user_assigned=None):
    if system_assigned is False and user_assigned is None:
        error_msg = 'Please specify either system assigned identity or a user assigned identity'
        raise ValidationError(error_msg)
    account_info = client.get(resource_group_name,
                              account_name) if resource_group_name else client.get_by_subscription(account_name)
    if account_info.identity is None:
        current_identity_types = []
    else:
        current_identity_types = account_info.identity.type.split(',')
        if 'None' in current_identity_types:
            current_identity_types = []
    media_service = MediaServiceUpdate(identity=MediaServiceIdentity(type=''))
    if system_assigned and 'SystemAssigned' not in current_identity_types:
        current_identity_types.append('SystemAssigned')
    user_id_dict = {}
    if user_assigned:
        if 'UserAssigned' not in current_identity_types:
            current_identity_types.append('UserAssigned')
        for user_id in user_assigned:
            user_id_dict[user_id] = {}
        media_service.identity.user_assigned_identities = user_id_dict
    identity_type = ','.join(current_identity_types)
    media_service.identity.type = identity_type
    return client.update(resource_group_name, account_name, media_service)