Why lab sessions are handled by TAs? Consider a course (say machine learning). Professors attend to deal with a theoretical part and then does not involve in the coding part.
The task of handling the coding part is left to the TAs of the course.
What is the reason behind this?
I am asking this question because I personally feel that dealing with a theoretical part does not need any expertise in the coding part. But coding part expects expertise in both the areas.  (Why difficult part is assigned to TAs?). Am I wrong anywhere?
I think your question extends beyond programming-related courses and also applies to virtually any course with a significant hands-on laboratory component (think chemistry labs, biology labs, physics labs, etc).
The main reason that TAs or lab instructors are used in these subjects is because hands-on instruction does not scale as well as lecture-style instruction. A professor can easily lecture about an algorithm to hundreds of students at the same time. But can the professor also help hundreds of students implement and debug the algorithm on their computers? Not very efficiently.
This is why TAs and lab instructors are hired. They can provide more individualized guidance and instruction with hands-on learning than a single professor probably ever could, and they are much cheaper.