<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def servers_with_roles(self, roles, env=None, match_all=False):
 """ Get servers with the given roles. If env is given, then the environment must match as well. If match_all is True, then only return servers who have all of the given roles. Otherwise, return servers that have one or more of the given roles. """

        result = []
        roles = set(roles)
        for instance in self.server_details():
            instroles = set(instance['roles'])
            envmatches = (env is None) or (instance['environment'] == env)
            if envmatches and match_all and roles <= instroles:
                result.append(instance)
            elif envmatches and not match_all and len(roles & instroles) > 0:
                result.append(instance)
        return result