This code may be more clear
from torch.optim import lr_scheduler
import torch.nn as nn
import torch
class network(torch.nn.Module):
    def __init__(self):
        nn.Module.__init__(self)
        self.layer=nn.Sequential(
            nn.Linear(4096, 2048),
            nn.ReLU(),
            nn.Linear(2048, 1024),
            nn.ReLU(),
            nn.Linear(1024, 512),
            nn.ReLU(),
        )
    def forward(self, ftr):
        pass
device=torch.device('cuda:0')


for i in range(100**100):
    print(i)
    net = network().to(device)
    optimizer = torch.optim.SGD(net.parameters(), lr=0.01, momentum=0.9,
                                weight_decay=0.9)
    scheduler = lr_scheduler.StepLR(optimizer, step_size=7, gamma=0.9)

    for epoch in range(1000*100):

        optimizer.step()
        scheduler.step()