It is possible to assign a template to a child term by code?

I have several child terms that i want to assign a template, but i prefer using code (looping to these child terms i need to assign) instead of manually selecting them on the template builder (i have parent terms with different usage on the child terms so i can’t assing a template to every child that exist).

Thanks!