input: Write a function that implements a simple linear regression model in Python, reading data from a CSV file, training the model, making predictions, and visualizing the results. Assume that the CSV file contains two columns named 'X' and 'Y'. Return the trained model and plot the regression line.
  
  
  import pandas as pd
  import matplotlib.pyplot as plt
  from sklearn import linear_model
  
  def simple_linear_regression():
      # Read data from CSV
      data = pd.read_csv('data.csv')
  
      # Set X and Y
      X = data['X'].values.reshape(-1, 1)
      Y = data['Y'].values
  
      # Create linear regression model
      model = linear_model.LinearRegression()
  
      # Train the model
      model.fit(X, Y)
  
      # Make predictions
      Y_pred = model.predict(X)
  
      # Visualize the results
      plt.scatter(X, Y)
      plt.plot(X, Y_pred, color='red')
      plt.show()
  
      return model
  
  # Testing the function
  assert type(simple_linear_regression()) == linear_model.LinearRegression
  
output: import pandas as pd
  import matplotlib.pyplot as plt
  from sklearn import linear_model
  
  def simple_linear_regression():
      data = pd.read_csv('data.csv')
      X = data['X'].values.reshape(-1, 1)
      Y = data['Y'].values
      model = linear_model.LinearRegression()
      model.fit(X, Y)
      Y_pred = model.predict(X)
      plt.scatter(X, Y)
      plt.plot(X, Y_pred, color='red')
      plt.show()
      return model