code: def _all_dims(x, default_dims=None):
    
    if x.get_shape().ndims is not None:
      return list(xrange(x.get_shape().ndims))
    else:
      return default_dims
docs: Returns a list of dims in x or default_dims if the rank is unknown.