Thanks, this solved one of the problems i had.
But it makes this below snippet throw an error because self.get_convolved_word_embeddings(char_tensor) expects the cuda tensor but char_tensor is FloatTensor, is there a way solve this. I tried char_tensor.cuda() and char_tensor.to(device). Both of the statements solve the issue but it throws the same error in the next line.
def create_question_char_embeddings(self,text):
        doc = nlp(text)
        embed = torch.zeros(20,60)
        for index,token in enumerate(doc):
            char_tensor = torch.zeros(50,45)
            for i,char in enumerate(token.text):
                try:
                    char_tensor[:,i] = torch.tensor(char_embeddings[char])
                except:
                    pass
            char_embedding = self.get_convolved_word_embeddings(char_tensor)
            embed[:,index] = char_embedding.squeeze(0).squeeze(1)
        return embed


Sorry if it is silly question.