tf.contrib.layers.xavier_initializer() tf2

shape = (3,3)
initializer = tf.initializers.GlorotUniform()
var = tf.Variable(initializer(shape=shape))

Here is what the above code is Doing:
1. We create a shape variable, which is a tuple of the dimensions of the tensor we want to create.
2. We create an initializer variable, which is an instance of the GlorotUniform class.
3. We create a variable var, which is a tensor of the shape we specified, and initialized with the initializer we specified.