input: Write a function that generates a linear regression model in Python using the given data in a CSV file and visualizes the regression line on a scatter plot. The function should use the pandas library to read the CSV, the `linear_model` module from sklearn to create and train the model, and matplotlib to plot the results. The function should return the trained model.
  def generate_linear_regression_model(csv_file):
      import pandas as pd
      import matplotlib.pyplot as plt
      from sklearn import linear_model
  
      # Read data from CSV
      data = pd.read_csv(csv_file)
  
      # Set X and Y
      X = data[['X']]
      Y = data['Y']
  
      # 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
  
  assert type(generate_linear_regression_model('data.csv')) == linear_model.LinearRegression
output: def generate_linear_regression_model(csv_file):
      import pandas as pd
      import matplotlib.pyplot as plt
      from sklearn import linear_model
  
      data = pd.read_csv(csv_file)
      X = data[['X']]
      Y = data['Y']
      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