input: Write a python function to create and train an LSTM encoder-decoder model with Keras.
  assert isinstance(create_and_train_model(np.random.rand(100, 1000), np.random.rand(100)), keras.models.Model)
  assert create_and_train_model(np.random.rand(100, 1000), np.random.rand(100)).loss == 'binary_crossentropy'
  assert create_and_train_model(np.random.rand(100, 1000), np.random.rand(100)).optimizer == 'adam'
output: def create_and_train_model(X, y):
      from keras.models import Model
      from keras.layers import Input, LSTM, RepeatVector, TimeDistributed, Dense
      from keras.optimizers import Adam
      import numpy as np
      
      timesteps = X.shape[1]
      input_dim = X.shape[2] if len(X.shape) > 2 else 1
  
      # Define an input sequence and process it with an LSTM
      inputs = Input(shape=(timesteps, input_dim))
      encoded = LSTM(128)(inputs)
  
      # Repeat the encoded vector
      decoded = RepeatVector(timesteps)(encoded)
  
      # Decode the sequence
      decoded = LSTM(128, return_sequences=True)(decoded)
      decoded = TimeDistributed(Dense(input_dim, activation='sigmoid'))(decoded)
  
      # Define the model
      autoencoder = Model(inputs, decoded)
      autoencoder.compile(optimizer='adam', loss='binary_crossentropy')
  
      # Reshape y if it's a 1D array to match the output shape
      if len(y.shape) == 1:
          y = np.expand_dims(y, axis=-1)
      y = np.tile(y, (1, timesteps, input_dim))
  
      # Train the model
      autoencoder.fit(X, y, epochs=10, batch_size=32, shuffle=True, validation_split=0.2)
  
      return autoencoder