def tensor_dim(tensor, dim):
 result = tensor.get_shape().as_list()[dim]
 if (result is None):
  result = tf.shape(tensor)[dim]
 return result

def tensor_dim ( tensor , dim ) : result = tensor . get_shape ( ) . as_list ( ) [ dim ] if ( result is None ) : result = tf . shape ( tensor ) [ dim ] return result
returns int dimension if known at a graph build time else a tensor .