<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def srem(self, key, *values):
 """Emulate srem."""

        redis_set = self._get_set(key, 'SREM')
        if not redis_set:
            return 0
        before_count = len(redis_set)
        for value in values:
            redis_set.discard(self._encode(value))
        after_count = len(redis_set)
        if before_count > 0 and len(redis_set) == 0:
            self.delete(key)
        return before_count - after_count