I appreciate your time to help me.
even I do not detach it, it does not work and the parameters are same size as before extending.
could you please have a look at part of my code:
   for epoch in range(1, n_epochs+1):
        
        
        train_loss = calc_forward(train_tu, train_tc, model, loss_fn, is_train=True)
        val_loss = calc_forward(val_tu, val_tc, model, loss_fn, is_train=False)
        
        
        optimizer.zero_grad()
        train_loss.backward()
        optimizer.step()
        
        
     
    for name, param in model.named_parameters():

        if name == '0.weight':
            
            param = torch.nn.functional.pad(param, (0,0,0,1), "constant", 1.0).requires_grad_()
            
        if name == '0.bias':
            
            param = torch.nn.functional.pad(param, (0,1), "constant", 1.0).requires_grad_()

        if name == '2.weight':
            
            param = torch.nn.functional.pad(param, (0,1,0,0), "constant", 1.0).requires_grad_()

        if name == '2.bias':
            print(name, param.shape, param)
            param = torch.nn.functional.pad(param, (0,1), "constant", 1.0).requires_grad_()
            print(param.shape, param)
            
    for epoch in range(1, n_epochs+1):
        
        
        train_loss = calc_forward(train_tu, train_tc, model, loss_fn, is_train=True)
        val_loss = calc_forward(val_tu, val_tc, model, loss_fn, is_train=False)
        
        
        optimizer.zero_grad()
        train_loss.backward()
        optimizer.step()
        
        
    for name, param in model.named_parameters():
        print(name, param.shape, param)

my model is really simple:
model = nn.Sequential(nn.Linear(1, 4), nn.Tanh(), nn.Linear(4, 1))