code: def run_loss(args):
      data = args["data"]
  
      # For each run we want to get a new random balance
      data.process()
      # split, train, test
      dense_out = len(data.labels[0])
      # split for all models
      X_train_, X_test_, Y_train, Y_test = train_test_split(
          data.text, data.labels, test_size=0.20, random_state=42
      )
  
      print(args)
  
      # Prep data for the LSTM model
      # This currently will train the tokenizer on all text (unbalanced and train/test)
      # It would be nice to replace this with a pretrained embedding on larger text
  
      tokenizer = Tokenizer(
          num_words=int(args["max_features"]), split=" "
      )
      tokenizer.fit_on_texts(data.all_text)
      X_train = tokenizer.texts_to_sequences(X_train_)
      X_train = pad_sequences(X_train, maxlen=max_len)
      X_test = tokenizer.texts_to_sequences(X_test_)
      X_test = pad_sequences(X_test, maxlen=max_len)
  
      # Train the LSTM model
      lstm_model = simple_lstm(
          int(args["max_features"]),
          dense_out,
          X_train.shape[1],
          int(args["embed_dim"]),
          int(args["lstm_out"]),
          args["dropout"],
      )
  
      if args["epochs"] == 0:
          args["epochs"] = 1
  
      es = EarlyStopping(
          monitor="val_acc",
          min_delta=0,
          patience=6,
          verbose=0,
          mode="max",
      )
      model_hist = lstm_model.fit(
          X_train,
          Y_train,
          epochs=args["epochs"],
          batch_size=batch_size,
          verbose=1,
          validation_data=(X_test, Y_test),
          callbacks=[es],
      )
      lstm_acc = model_hist.history["val_acc"][-1]
      print("LSTM model accuracy ", lstm_acc)
      # This minimizes, so the maximize we have to take the inverse :)
      return 1 - lstm_acc
  
file_path: nlp-architect/examples/supervised_sentiment/optimize_example.py
imports: import argparse
  import pickle
  from hyperopt import fmin, tpe, hp, Trials
  from sklearn.model_selection import train_test_split
  from tensorflow.python.keras.callbacks import EarlyStopping
  from tensorflow.python.keras.preprocessing.sequence import pad_sequences
  from tensorflow.python.keras.preprocessing.text import Tokenizer
  from examples.supervised_sentiment.amazon_reviews import Amazon_Reviews
  from nlp_architect.utils.io import validate_parent_exists, check_size, validate_existing_filepath
  from .supervised_sentiment import simple_lstm
label_desc: Use image node_id 1 for calling a global function with example usage: run_loss(args) and returns: unknown