Can this do the trick?
import torch

emb_dim = 1
hidden_dim = 2
n_layers = 2
bidirectional = False
dropout = 0.1

pattern = "weight_hh_l"


torch.manual_seed(0)
model1 = torch.nn.LSTM(emb_dim, hidden_dim, num_layers = n_layers, bidirectional=bidirectional, dropout = 0 if n_layers < 2 else dropout)

{k : v for k, v in model1.state_dict().items() if k.startswith(pattern)}
"""
{'weight_hh_l0': tensor([[-0.0628,  0.1871],
         [-0.2137, -0.1390],
         [-0.6755, -0.4683],
         [-0.2915,  0.0262],
         [ 0.2795,  0.4243],
         [-0.4794, -0.3079],
         [ 0.2568,  0.5872],
         [-0.1455,  0.5291]]), 'weight_hh_l1': tensor([[ 0.1318, -0.5482],
         [-0.4901, -0.3653],
         [ 0.3199,  0.2844],
         [-0.4189,  0.2136],
         [ 0.3882, -0.0892],
         [ 0.0270,  0.1638],
         [ 0.4387,  0.6790],
         [-0.5449, -0.2591]])}
"""


torch.manual_seed(1)
model2 = torch.nn.LSTM(emb_dim, hidden_dim, num_layers = n_layers, bidirectional=bidirectional, dropout = 0 if n_layers < 2 else dropout)

{k : v for k, v in model2.state_dict().items() if k.startswith(pattern)}
"""
{'weight_hh_l0': tensor([[ 0.0983, -0.0866],
         [ 0.1961,  0.0349],
         [ 0.2583, -0.2756],
         [-0.0516, -0.0637],
         [ 0.1025, -0.0028],
         [ 0.6181,  0.2200],
         [-0.2633, -0.4271],
         [-0.1185, -0.3050]]), 'weight_hh_l1': tensor([[-0.0331, -0.4720],
         [ 0.4306,  0.2195],
         [-0.4571,  0.4593],
         [ 0.4293,  0.6271],
         [-0.3964, -0.1164],
         [-0.0137,  0.1033],
         [-0.5366, -0.5018],
         [ 0.3847, -0.1658]])}
"""

state_dict = {}
for item1, item2 in zip(model1.state_dict().items(), model2.state_dict().items()) :
    key = item1[0] # = item2[0] 
    if key.startswith(pattern) : # or another condition ...
        state_dict[key] = item1[1] # take one of model1
    else :
        state_dict[key] = item2[1] # take one of model2


model2.load_state_dict(state_dict)
"""
<All keys matched successfully>
"""


#assert {k : v for k, v in model1.state_dict().items() if k.startswith(pattern)} "costum =" {k : v for k, v in model2.state_dict().items() if k.startswith(pattern)}
"""
True
"""