<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_activity(self, activity_id, name=None, activity_type=None, private=None, commute=None, trainer=None, gear_id=None, description=None,device_name=None):
 """ Updates the properties of a specific activity. http://strava.github.io/api/v3/activities/#put-updates :param activity_id: The ID of the activity to update. :type activity_id: int :param name: The name of the activity. :param activity_type: The activity type (case-insensitive). Possible values: ride, run, swim, workout, hike, walk, nordicski, alpineski, backcountryski, iceskate, inlineskate, kitesurf, rollerski, windsurf, workout, snowboard, snowshoe :param private: Whether the activity is private. :param commute: Whether the activity is a commute. :param trainer: Whether this is a trainer activity. :param gear_id: Alpha-numeric ID of gear (bike, shoes) used on this activity. :param description: Description for the activity. :param device_name: Device name for the activity :return: The updated activity. :rtype: :class:`stravalib.model.Activity` """


        # Convert the kwargs into a params dict
        params = {}

        if name is not None:
            params['name'] = name

        if activity_type is not None:
            if not activity_type.lower() in [t.lower() for t in model.Activity.TYPES]:
                raise ValueError("Invalid activity type: {0}.  Possible values: {1!r}".format(activity_type, model.Activity.TYPES))
            params['type'] = activity_type

        if private is not None:
            params['private'] = int(private)

        if commute is not None:
            params['commute'] = int(commute)

        if trainer is not None:
            params['trainer'] = int(trainer)

        if gear_id is not None:
            params['gear_id'] = gear_id

        if description is not None:
            params['description'] = description
            
        if device_name is not None:
            params['device_name'] = device_name

        raw_activity = self.protocol.put('/activities/{activity_id}', activity_id=activity_id, **params)

        return model.Activity.deserialize(raw_activity, bind_client=self)