It seems that this code was developed against older version. Apparently in tensorflow 2.4.0 there is no tensorflow.contrib module.