To download the skipthoughts library
!pip install skipthoughts

Importing libraries and initialising them
If it helps here is the link on how to use it, I followed their steps -> link
from skipthoughts import UniSkip, BiSkip
dir_st = 'skip-thoughts'
# Note that the word dict here is something I created
uniskip = UniSkip(dir_st, tokenizer.word_dict).cuda() pretrained
biskip = BiSkip(dir_st, tokenizer.word_dict).cuda()

I use the function below to convert any sentence to embeddings
def convert_text_to_embeddings(batch_text):
  tokenized_labels, lengths = tokenizer.convert_batch_sentences_to_indices(batch_text)
  uni_out = uniskip(tokenized_labels, lengths)
  bi_out = biskip(tokenized_labels, lengths)
  return torch.cat([uni_out, bi_out], dim=1) # Note I add detach here to avoid the error

Below is my training step (please let me know if you would like to see my model architecture too)
pbar = tqdm()

# Converting dataset to cuda

for epoch in range(epochs):
    print(f'Epoch: {epoch + 1} / {epochs}')
    pbar.reset(total=len(weighted_dataloader))

    # Setting up losses
    discriminator_losses = []
    generator_losses = []

    for i, (real_images, real_text) in enumerate(weighted_dataloader):

        # Current batch size
        current_batch_size = real_images.size()[0]

        # Convert to cuda
        real_images = real_images.cuda()
        text_embeddings = convert_text_to_embeddings(real_text)

        # For real vs fake
        real_validity = torch.ones(current_batch_size, 1).cuda()
        fake_validity = torch.zeros(current_batch_size, 1).cuda()

        # Train Generator
        generator.zero_grad()
        input_noise = torch.randn(size=(current_batch_size, noise_size)).cuda()
        fake_images = generator(input_noise, text_embeddings)
        discriminator_fake_validity = discriminator(fake_images, text_embeddings)
        generator_loss = adversarial_loss(discriminator_fake_validity, real_validity)

        generator_loss.backward() # Does not work even if I set retain_graph to True
        generator.optimizer.step()
        generator_losses.append(generator_loss)

        # Train Discriminator
        discriminator.zero_grad()

        ## To calculate real loss
        discriminator_real_validity = discriminator(real_images, text_embeddings)
        discriminator_real_loss = adversarial_loss(discriminator_real_validity, real_validity)

        ## To calculate wrong loss
        mismatched_images = torch.cat([real_images[1:], real_images[:1]], dim=0)
        discriminator_wrong_validity = discriminator(mismatched_images, text_embeddings)
        discriminator_wrong_loss = adversarial_loss(discriminator_wrong_validity, fake_validity)

        ## To calculate fake loss
        discriminator_fake_validity = discriminator(fake_images.detach(), text_embeddings)
        discriminator_fake_loss = adversarial_loss(discriminator_fake_validity, fake_validity)

        ## Calculating total loss
        discriminator_loss = discriminator_real_loss + discriminator_wrong_loss + discriminator_fake_loss
        discriminator_loss.backward()
        discriminator.optimizer.step()
        discriminator_losses.append(discriminator_loss)


        # Update tqdm
        pbar.update()

    print('Discriminator Loss: {:.3f}, Generator Loss: {:.3f}'.format(
            torch.mean(torch.FloatTensor(discriminator_losses)),
            torch.mean(torch.FloatTensor(generator_losses))
    ))
    
    if (epoch + 1) % output_after_every_n == 0:
        plot_output()

pbar.refresh()

Do let me know if I have missed out on anything you’d like to know.
Thanks!