fix(count_tokens): backport October 19 fixes to stable/1.104.x (cherry picked from commit 5e4d160423)
5e4d160423