AttributeError: module ‘tensorflow.compat.v2’ has no attribute ‘depth_to_space’

  python, tensorflow, tensorflow1.15

I am trying to run a code, which was written with tensorflow version 1.4.0
I am running my code on google colab which gives in tensorflow version 2.x with it.

To run my code, I am using backward compatibility like:
replacing import tensorflow as tf with

import tensorflow.compat.v1 as tf

which works for certain things, but at a point it comes down to this error

AttributeError: module ‘tensorflow.compat.v2’ has no attribute ‘depth_to_space’

as you can see in this image

What I am not able to understand is this method ‘depth_to_space’ is in both versions of tensorflow 1.x and 2.x , then why is my version of tensorflow not getting it ?
Here’s the link to the method in version 1.x:

Please help me understand what’s the cause of this error.


Source: Python Questions