code: def load_tf_s2s(
      filepath: Union[str, os.PathLike], state_dict: Dict
  ) -> tf.keras.Model:
      """
      Load seq2seq TensorFlow model.
  
      Parameters
      ----------
      filepath
          Saved model directory.
      state_dict
          Dictionary containing the `latent_dim`, `shape`, `output_activation` and `beta` parameters.
  
      Returns
      -------
      Loaded seq2seq model.
      """
      model_dir = Path(filepath).joinpath("model")
      if not [f.name for f in model_dir.glob("[!.]*.h5")]:
          logger.warning(
              "No seq2seq or threshold estimation net found in {}.".format(
                  model_dir
              )
          )
          return None
      # load threshold estimator net, initialize encoder and decoder and load seq2seq weights
      threshold_net = tf.keras.models.load_model(
          model_dir.joinpath("threshold_net.h5"), compile=False
      )
      latent_dim = state_dict["latent_dim"]
      n_features = state_dict["shape"][-1]
      encoder_net = EncoderLSTM(latent_dim)
      decoder_net = DecoderLSTM(
          latent_dim, n_features, state_dict["output_activation"]
      )
      seq2seq = Seq2Seq(
          encoder_net,
          decoder_net,
          threshold_net,
          n_features,
          beta=state_dict["beta"],
      )
      seq2seq.load_weights(model_dir.joinpath("seq2seq.ckpt"))
      return seq2seq
  
imports: import logging
  import os
  from importlib import import_module
  import warnings
  from functools import partial
  from pathlib import Path
  from typing import Callable, Dict, List, Optional, Tuple, Union, Type
  import dill
  import tensorflow
  from tensorflow_probability.python.distributions.distribution import Distribution
  from transformers import AutoTokenizer
  from alibi_detect.ad import AdversarialAE, ModelDistillation
  from alibi_detect.ad.adversarialae import DenseHidden
  from alibi_detect.cd import ChiSquareDrift, ClassifierDrift, KSDrift, MMDDrift, TabularDrift
  from alibi_detect.cd.tensorflow import UAE, HiddenOutput
  from alibi_detect.cd.tensorflow.preprocess import _Encoder
  from alibi_detect.models.tensorflow import PixelCNN, TransformerEmbedding
  from alibi_detect.models.tensorflow.autoencoder import AE, AEGMM, VAE, VAEGMM, DecoderLSTM, EncoderLSTM, Seq2Seq
  from alibi_detect.od import LLR, IForest, Mahalanobis, OutlierAE, OutlierAEGMM, OutlierProphet, OutlierSeq2Seq, OutlierVAE, OutlierVAEGMM, SpectralResidual
  from alibi_detect.od.llr import build_model
  from alibi_detect.utils.tensorflow.kernels import DeepKernel
  from alibi_detect.utils.frameworks import Framework
  from alibi_detect.version import __version__
  from alibi_detect.base import Detector
  from alibi_detect.saving._typing import VALID_DETECTORS
label_desc: Use image node_id 12 for calling a global function with example usage: load_tf_s2s(filepath, state_dict) and returns: seq2seq, None