That is my total code script:
class Model(nn.Module):
    def __init__(self,in_dim,hidden_dim,num_classes):
        super(Model, self).__init__()
        self.layer1 = nn.Linear(in_dim,hidden_dim)
        self.layer2 = nn.Linear(hidden_dim,hidden_dim)
        self.layer3 = nn.Linear(hidden_dim,num_classes)
        self.relu = nn.ReLU()

    def forward(self,x):
        a = self.relu(self.layer1(x))
        a = self.relu(self.layer2(a))
        return self.relu(self.layer3(a))  

model = Model(32,32,1)

def train(epoch,L):
    criteria = nn.MSELoss()
    learning_rate = 0.1
    optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)

    t = np.linspace(0,2,L+2)       
    fs = L+2
    
    trn_loss = list()
        
    for f in range(0,epoch):
        phase = f/np.pi      
        x = np.sin(2*np.pi*t*fs+phase)
        
        x_train = torch.from_numpy(x[:-2]).float()
        x_train = x_train.unsqueeze(0)
        
        x_test = torch.tensor(x[-2]).float()
        x_test = torch.reshape(x_test,(1,1))
        
        optimizer.zero_grad()
        
        x_hat = model(x_train)
            
        currentCost = criteria(x_hat,x_test)
        
        trn_loss.append(currentCost.item())
        currentCost.backward()
        print(model.layer3.weight.grad)
        optimizer.step()
                
    plt.plot(range(1,epoch+1),trn_loss,c='orangered')

train(100,32)


and output is now for every epoch:
tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0.]])