input: Write a python function to train a linear regression model and evaluate its performance using mean squared error, mean absolute error, and r2 score.
  assert train_and_evaluate_model('Boston.csv') == {'mse': 10.123456, 'mae': 2.345678, 'r2': 0.876543}
  assert train_and_evaluate_model('SampleData.csv') == {'mse': 5.678901, 'mae': 1.234567, 'r2': 0.987654}
  assert train_and_evaluate_model('AnotherData.csv') == {'mse': 15.234567, 'mae': 3.456789, 'r2': 0.765432}
output: def train_and_evaluate_model(csv_file):
      import pandas as pd
      from sklearn.model_selection import train_test_split
      from sklearn.linear_model import LinearRegression
      from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
  
      # Load the dataset
      data = pd.read_csv(csv_file)
      
      # Assuming the last column is the target and all other columns are features
      X = data.iloc[:, :-1]
      y = data.iloc[:, -1]
      
      # Split the dataset into training and testing sets
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
      
      # Train the linear regression model
      model = LinearRegression()
      model.fit(X_train, y_train)
      
      # Make predictions on the test set
      y_pred = model.predict(X_test)
      
      # Calculate performance metrics
      mse = mean_squared_error(y_test, y_pred)
      mae = mean_absolute_error(y_test, y_pred)
      r2 = r2_score(y_test, y_pred)
      
      # Return the performance metrics in a dictionary
      return {'mse': mse, 'mae': mae, 'r2': r2}