word_to_ix = {"hello": 0, "world": 1} [embeds](https://docs.pytorch.org/docs/stable/generated/torch.nn.Embedding.html#torch.nn.Embedding "torch.nn.Embedding") = [nn.Embedding](https://docs.pytorch.org/docs/stable/generated/torch.nn.Embedding.html#torch.nn.Embedding "torch.nn.Embedding")(2, 5) # 2 words in vocab, 5 dimensional embeddings [lookup_tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "torch.Tensor") = [torch.tensor](https://docs.pytorch.org/docs/stable/generated/torch.tensor.html#torch.tensor "torch.tensor")([word_to_ix["hello"]], dtype=[torch.long](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.dtype "torch.dtype")) [hello_embed](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "torch.Tensor") = [embeds](https://docs.pytorch.org/docs/stable/generated/torch.nn.Embedding.html#torch.nn.Embedding "torch.nn.Embedding")([lookup_tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "torch.Tensor")) print([hello_embed](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "torch.Tensor"))