for i in range(len(videos)):
            try:
                video_d = np.load(os.path.join(VIDEO_DATA_PATH,videos[i]))
                video_d = video_d.transpose(0, 3, 1, 2)
                for j in range(video_d.shape[0]):
                    video_d[j] = (video_d[j] - video_d[j].min())/(video_d[j].max() - video_d[j].min())
                video_d = torch.from_numpy(video_d)

                print(video_d.shape)
                video_data = Variable(video_d)  # this needs to be array of still frames

                audio_d = np.load(os.path.join(AUDIO_DATA_PATH,audios[i]))
                audio_d = torch.from_numpy(audio_d)
                audio_d = audio_d.view(audio_d.size()[0], audio_d.size()[2], audio_d.size()[1])
                audio_data = Variable(audio_d)

                MINIBATCHSIZE = video_d.size()[0]

                still_frame = video_d[2]
                # To show a still frame
                # show_image(still_frame.numpy())

                still_frame = still_frame.view(1, still_frame.size()[0], still_frame.size()[1], still_frame.size()[2])
                still_frame = Variable(still_frame.repeat(MINIBATCHSIZE, 1, 1, 1))
                noise_data = Variable(torch.rand(MINIBATCHSIZE, 1, NOISE_OUTPUT))
                # print(noise_data.size())
                noise_data = noise_data.data.resize_(noise_data.size()).normal_(0, 0.6)
                # plt.imshow(noise_data.numpy())
                # plt.show()
                # print(noise_data)
                # print(noise_data.size())

                if cuda:
                    audio_data = audio_data.cuda()
                    video_data = video_data.cuda()
                    noise_data = noise_data.cuda()
                    still_frame = still_frame.cuda()

                # Train Generator
                # print(audio_data.size())
                # print(video_data.size())
                # print(still_frame.size())
                optimizer_unet.zero_grad()
                optimizer_fd.zero_grad()
                optimizer_sd.zero_grad()

                gen_frames = unet(still_frame, audio_data, noise_data)
                # print(gen_frames[0])

                # img = gen_frames[random.randint(0, MINIBATCHSIZE -1)].cpu().detach().numpy().transpose(1, 2, 0)
                # cv2.imwrite('./logs/'+str(time.time())+'.jpg', img)


                #print(gen_frames.size())
                #img = gen_frames[0].detach().numpy()
                #show_image(img)
                #return
                # print("Generated frames ", gen_frames.size())

                Lambda = 10
                # print(video_data[0])
                # print(torch.mean(torch.mean(torch.mean(torch.abs(video_data - gen_frames), 1), 1), 1))

                print(torch.mean(torch.mean(torch.mean(torch.mean(torch.abs(video_data - gen_frames), 1), 1), 1)))
                # return
                l1_loss = torch.mean(torch.mean(torch.mean(torch.mean(torch.abs(video_data - gen_frames), 1), 1), 1))
                print(l1_loss)
                # return


                out1 = frame_discriminator(video_data, still_frame)
                out2 = frame_discriminator(gen_frames, still_frame)

                out3 = sequence_discriminator(video_data, audio_data)
                out4 = sequence_discriminator(gen_frames, audio_data)
                # print(out1)
                # print("out is ", out3.size())

                # d_loss = -dis_loss(out2, out1, out4 ,out3)
                frame_loss = fdis_loss(out2, out1)
                sequence_loss = sdis_loss(out4, out3)
                d_loss = -(frame_loss + sequence_loss)

                g_loss = -gen_loss(out2, out4) + Lambda*l1_loss
                g_loss.backward(retain_graph=True)
                optimizer_unet.step()

                d_loss.backward()
                optimizer_fd.step()
                optimizer_sd.step()


                print("G loss {} FD loss {} SD loss {}".format(g_loss.data, frame_loss.data, sequence_loss.data))
                batch_g_loss += g_loss.data
                batch_d_loss += d_loss.data
                tock = time.time()
                print("Epoch {}, Done for file: {}  Total time elapsed {} hr".format(epoch, videos[i], (tock-tick)/(60*60)))
            except Exception as e:
                rejected += 1
                print(e)
                print("Something went wrong with the file {}".format(videos[i]))