def split_no_wd_params(layer_groups:Collection[nn.Module])->List[List[nn.Parameter]]:
    "Separate the parameters in `layer_groups` between `no_wd_types` and  bias (`bias_types`) from the rest."
    split_params = []
    for l in layer_groups:
        l1,l2 = [],[]
        for c in l.children():
            if isinstance(c, no_wd_types): l2 += list(trainable_params(c))
            elif isinstance(c, bias_types):
                bias = c.bias if hasattr(c, 'bias') else None
                l1 += [p for p in trainable_params(c) if not (p is bias)]
                if bias is not None: l2.append(bias)
            else: l1 += list(trainable_params(c))
        #Since we scan the children separately, we might get duplicates (tied weights). We need to preserve the order
        #for the optimizer load of state_dict
        l1,l2 = uniqueify(l1),uniqueify(l2)
        split_params += [l1, l2]
    return split_params
def split_no_wd_params ( layer_groups : Collection [ nn . Module ] ) -> List [ List [ nn . Parameter ] ] : split_params = [ ] for l in layer_groups : l1 , l2 = [ ] , [ ] for c in l . children ( ) : if isinstance ( c , no_wd_types ) : l2 += list ( trainable_params ( c ) ) elif isinstance ( c , bias_types ) : bias = c . bias if hasattr ( c , 'bias' ) else None l1 += [ p for p in trainable_params ( c ) if not ( p is bias ) ] if bias is not None : l2 . append ( bias ) else : l1 += list ( trainable_params ( c ) ) l1 , l2 = uniqueify ( l1 ) , uniqueify ( l2 ) split_params += [ l1 , l2 ] return split_params
Separate the parameters in `layer_groups` between `no_wd_types` and  bias (`bias_types`) from the rest.