import torch import pickle class TimeSeriesAnomalyDetectionHandler: def __init__(self): # Load the model from the .pt file with open("lstm_ed.pt", "rb") as f: self.model = torch.load(f) def __call__(self, event, context): # Parse the input data from the event data = event["data"] inputs = data # Run the model inference with torch.no_grad(): outputs = self.model.predict(**inputs) # Process the model outputs predictions = outputs # Return the predictions return {"predictions": predictions}