def METHOD_NAME(self, path: Path) -> torch.Tensor:
    """Tokenizes a text file."""
    assert path.exists()
    # Add words to the dictionary
    with open(path, "r", encoding="utf8") as f:
        for line in f:
            words = line.split() + ["<eos>"]
            for word in words:
                self.dictionary.add_word(word)
    # Tokenize file content
    with open(path, "r", encoding="utf8") as f:
        idss = []
        for line in f:
            words = line.split() + ["<eos>"]
            ids = []
            for word in words:
                ids.append(self.dictionary.word2idx[word])
            idss.append(torch.tensor(ids).type(torch.int64))
        ids = torch.cat(idss)
    return ids