How do you edit Transformer and save weights?

I have a segformer of which I modified part of the first patch embedding with the following code:

modified_layer = nn.Conv2d(NUM_CHANNELS, 64, kernel_size=7, stride=4, padding=3)
model.segformer.encoder.patch_embeddings[0].proj = modified_layer

When I use the save_pretrained() method, it doesn’t save this modified patch embedding.