def METHOD_NAME(s, append_bos=False):
    if self.bpe is not None:
        s = self.bpe.encode(s)
    tokens = self.vocab.encode_line(
        s,
        append_eos=True,
        add_if_not_exist=False,
    ).long()
    if append_bos and self.args.init_token is not None:
        tokens = torch.cat([tokens.new([self.args.init_token]), tokens])
    return tokens