input: Write a python function to train and evaluate a logistic regression model on restaurant review data, including encoding ratings and vectorizing text reviews.
  assert train_and_evaluate_model() is not None
output: def train_and_evaluate_model():
      import pandas as pd
      from sklearn.model_selection import train_test_split
      from sklearn.feature_extraction.text import TfidfVectorizer
      from sklearn.linear_model import LogisticRegression
      from sklearn.metrics import accuracy_score
  
      # Sample data: Replace with actual restaurant review data
      data = {
          'review': ['The food was great!', 'Terrible service.', 'Loved the ambiance.', 'The food was okay.', 'Will not come back.'],
          'rating': [5, 1, 5, 3, 1]
      }
      df = pd.DataFrame(data)
  
      # Encode ratings: Good (rating >= 4), Bad (rating < 4)
      df['label'] = df['rating'].apply(lambda x: 1 if x >= 4 else 0)
  
      # Split the data into training and test sets
      X_train, X_test, y_train, y_test = train_test_split(df['review'], df['label'], test_size=0.2, random_state=42)
  
      # Vectorize text reviews
      vectorizer = TfidfVectorizer()
      X_train_vec = vectorizer.fit_transform(X_train)
      X_test_vec = vectorizer.transform(X_test)
  
      # Train logistic regression model
      model = LogisticRegression()
      model.fit(X_train_vec, y_train)
  
      # Evaluate model
      y_pred = model.predict(X_test_vec)
      accuracy = accuracy_score(y_test, y_pred)
  
      return accuracy