I am sorry you are having trouble reading your encoders. Thanks for posting your code; it looks fine.
encoders_init() function has four arguments (named m1a, m1b, m2a, and m2b) which are the four pins that the wheel encoders are connected to. The initialization function is designed with the intention that when motor M1 is spinning forward, pin m1a will change before pin m1b. However, it is difficult to get those connections all correct on the first try, and you might have to experiment. Can you try checking your connections to ensure your script is properly set up to count ticks?
If that does not help, can you tell me more about your system? What microcontroller are you using? How are you supplying power? Can you post pictures that clearly show how you have your optical encoder connected? Can you also verify that your encoder channels are outputting a usable signal by measuring their outputs when the motor is rotated by hand? If you have access to an oscilloscope, you should use that and look at the waveform and its magnitude. If you do not have access to an oscilloscope, you might try using a multimeter.