class_docstr: Defines Temporal Fusion Transformer.
  
  Attributes:
    name: Name of model
    time_steps: Total number of input time steps per forecast date (i.e. Width
      of Temporal fusion decoder N)
    input_size: Total number of inputs
    output_size: Total number of outputs
    category_counts: Number of categories per categorical variable
    n_multiprocessing_workers: Number of workers to use for parallel
      computations
    column_definition: List of tuples of (string, DataType, InputType) that
      define each column
    quantiles: Quantiles to forecast for TFT
    use_cudnn: Whether to use Keras CuDNNLSTM or standard LSTM layers
    hidden_layer_size: Internal state size of TFT
    dropout_rate: Dropout discard rate
    max_gradient_norm: Maximum norm for gradient clipping
    learning_rate: Initial learning rate of ADAM optimizer
    minibatch_size: Size of minibatches for training
    num_epochs: Maximum number of epochs for training
    early_stopping_patience: Maximum number of iterations of non-improvement
      before early stopping kicks in
    num_encoder_steps: Size of LSTM encoder -- i.e. number of past time steps
      before forecast date to use
    num_stacks: Number of self-attention layers to apply (default is 1 for basic
      TFT)
    num_heads: Number of heads for interpretable mulit-head attention
    model: Keras model for TFT
class_docstr_tok: ["Defines","Temporal","Fusion","Transformer",".","Attributes",":","name",":","Name","of","model","time_steps",":","Total","number","of","input","time","steps","per","forecast","date","(","i.e",".","Width","of","Temporal","fusion","decoder","N",")","input_size",":","Total","number","of","inputs","output_size",":","Total","number","of","outputs","category_counts",":","Number","of","categories","per","categorical","variable","n_multiprocessing_workers",":","Number","of","workers","to","use","for","parallel","computations","column_definition",":","List","of","tuples","of","(","string",",","DataType",",","InputType",")","that","define","each","column","quantiles",":","Quantiles","to","forecast","for","TFT","use_cudnn",":","Whether","to","use","Keras","CuDNNLSTM","or","standard","LSTM","layers","hidden_layer_size",":","Internal","state","size","of","TFT","dropout_rate",":","Dropout","discard","rate","max_gradient_norm",":","Maximum","norm","for","gradient","clipping","learning_rate",":","Initial","learning","rate","of","ADAM","optimizer","minibatch_size",":","Size","of","minibatches","for","training","num_epochs",":","Maximum","number","of","epochs","for","training","early_stopping_patience",":","Maximum","number","of","iterations","of","non-improvement","before","early","stopping","kicks","in","num_encoder_steps",":","Size","of","LSTM","encoder","--","i.e",".","number","of","past","time","steps","before","forecast","date","to","use","num_stacks",":","Number","of","self-attention","layers","to","apply","(","default","is","1","for","basic","TFT",")","num_heads",":","Number","of","heads","for","interpretable","mulit-head","attention","model",":","Keras","model","for","TFT"]
docstr: Builds TFT from parameters.
  
  Args:
    raw_params: Parameters to define TFT
    use_cudnn: Whether to use CUDNN GPU optimised LSTM
docstr_tok: ["Builds","TFT","from","parameters",".","Args",":","raw_params",":","Parameters","to","define","TFT","use_cudnn",":","Whether","to","use","CUDNN","GPU","optimised","LSTM"]
code: def __init__(self, raw_params, use_cudnn=False):
      """Builds TFT from parameters.
  
      Args:
        raw_params: Parameters to define TFT
        use_cudnn: Whether to use CUDNN GPU optimised LSTM
      """
  
      self.name = self.__class__.__name__
  
      params = dict(raw_params)  # copy locally
  
      # Data parameters
      self.time_steps = int(params["total_time_steps"])
      self.input_size = int(params["input_size"])
      self.output_size = int(params["output_size"])
      self.category_counts = json.loads(str(params["category_counts"]))
      self.n_multiprocessing_workers = int(
          params["multiprocessing_workers"]
      )
  
      # Relevant indices for TFT
      self._input_obs_loc = json.loads(str(params["input_obs_loc"]))
      self._static_input_loc = json.loads(
          str(params["static_input_loc"])
      )
      self._known_regular_input_idx = json.loads(
          str(params["known_regular_inputs"])
      )
      self._known_categorical_input_idx = json.loads(
          str(params["known_categorical_inputs"])
      )
  
      self.column_definition = params["column_definition"]
  
      # Network params
      self.quantiles = [0.1, 0.5, 0.9]
      self.use_cudnn = use_cudnn  # Whether to use GPU optimised LSTM
      self.hidden_layer_size = int(params["hidden_layer_size"])
      self.dropout_rate = float(params["dropout_rate"])
      self.max_gradient_norm = float(params["max_gradient_norm"])
      self.learning_rate = float(params["learning_rate"])
      self.minibatch_size = int(params["minibatch_size"])
      self.num_epochs = int(params["num_epochs"])
      self.early_stopping_patience = int(
          params["early_stopping_patience"]
      )
  
      self.num_encoder_steps = int(params["num_encoder_steps"])
      self.num_stacks = int(params["stack_size"])
      self.num_heads = int(params["num_heads"])
  
      # Serialisation options
      self._temp_folder = os.path.join(params["model_folder"], "tmp")
      self.reset_temp_folder()
  
      # Extra components to store Tensorflow nodes for attention computations
      self._input_placeholder = None
      self._attention_components = None
      self._prediction_parts = None
  
      print("*** {} params ***".format(self.name))
      for k in params:
          print("# {} = {}".format(k, params[k]))
  
      # Build model
      self.model = self.build_model()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gc
  import json
  import os
  import shutil
  import data_formatters.base
  import libs.utils
  import numpy
  import pandas
  import tensorflow
label_desc: Use image node_id 1 to create a new TemporalFusionTransformer object  with example: obj = TemporalFusionTransformer(raw_params, use_cudnn)