I feel like a complete idiot, sorry  I know I have something wrong, but i don’t quite understand (missing some skills here)…
def main(Gen_model_3D):
    ngpu = 1
    device = torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu")
    dataload = dataset3D(transform=None)

    dataloader = torch.utils.data.DataLoader(dataload, batch_size=20,
                                             shuffle=True, num_workers=2)
    model_3d = Gen_model_3D()
    optimizer_gen = torch.optim.Adam(model_3d.parameters(), lr=1E-5,
                                     weight_decay=1e-6)
    train(device,dataloader,model_3d,optimizer_gen)


def train(device,dataloader,model_3d,optimizer_gen):
    img_list=[]
    iters=0
    for epoch in range(10):
        for i,data in enumerate(dataloader):
            data_in=data['resize']

            data_in=data_in.cuda()
            data_in = data_in.type(torch.cuda.FloatTensor)
            # data_in = data_in.unsqueeze(1)

            optimizer_gen.zero_grad()
            loss,out = loss_fn(model_3d, data_in)
            loss.backward()
            print(loss)
            optimizer_gen.step()
if __name__ == '__main__':
    img_list =  main(Gen_model_3D)

gives:
NameError: name ‘model_3d’ is not defined