<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pick_key(keys, use, alg='', key_type='', kid=''):
 """ Based on given criteria pick out the keys that fulfill them from a given set of keys. :param keys: List of keys. These are :py:class:`cryptojwt.jwk.JWK` instances. :param use: What the key is going to be used for 'sig'/'enc' :param alg: crypto algorithm :param key_type: Type of key 'rsa'/'ec'/'oct' :param kid: Key ID :return: A list of keys that match the pattern """

    res = []
    if not key_type:
        if use == 'sig':
            key_type = jws_alg2keytype(alg)
        else:
            key_type = jwe_alg2keytype(alg)

    for key in keys:
        if key.use and key.use != use:
            continue

        if key.kty == key_type:
            if key.kid and kid:
                if key.kid == kid:
                    res.append(key)
                else:
                    continue

            if key.alg == '':
                if alg:
                    if key_type == 'EC':
                        if key.crv == 'P-{}'.format(alg[2:]):
                            res.append(key)
                        continue
                res.append(key)
            elif alg and key.alg == alg:
                res.append(key)
            else:
                res.append(key)
    return res