human
Solve the following python programming problem given the following code:
def updateAverageRating(review_key) : 
    'Helper function for updating the average rating of a product when new
  review(s) are added.' 
    def _tx() : 
        review = review_key.get () 
        product = review.product_key.get () 
        if (not review.rating_added) : 
            review.rating_added = True 
            product.num_reviews += 1 
            product.avg_rating = (product.avg_rating + ((review.rating - product.avg_rating) / float (product.num_reviews))) 
            product.needs_review_reindex = True 
            ndb.put_multi ([product, review]) 
            if (not config.BATCH_RATINGS_UPDATE) : 
                defer (models.Product.updateProdDocWithNewRating, product.key.id (), _transactional = True) 
return (product, review) 
try : 
        ndb.transaction (review_key, xg = True) 
except AttributeError : 
        logging.exception (('The function updateAverageRating failed. Either review ' + 'or product entity does not exist.')) 

    
    

    Fix the buggy line: ndb.transaction (review_key, xg = True)
assistant
#Here is Python program to fix the buggy line: ndb.

ndb.transaction (def _tx(, xg = True)