Change the Number of Layers of Pegasus model

I am trying to change the number of layers in a pretrained Huggingface Pegasus Model to see if the performance of the is improving or not. I tried updating the config function. But it generates index out of range error.

Following is the code I tried.

from transformers import PegasusConfig

config = PegasusConfig(
encoder_layers = 14,
encoder_attention_heads = 16,
decoder_layers = 14,
decoder_attention_heads = 16,
max_position_embeddings= 2048,

from transformers import pipeline, PegasusTokenizer, PegasusForConditionalGeneration

model = PegasusForConditionalGeneration.from_pretrained(‘google/pegasus-pubmed’,config = config, ignore_mismatched_sizes=True)