class_docstr: TFT Model
code: def fit(
      self,
      dataset: DatasetH,
      MODEL_FOLDER="qlib_tft_model",
      USE_GPU_ID=0,
      **kwargs,
  ):
      DATASET = self.params["DATASET"]
      LABEL_SHIFT = self.params["label_shift"]
      LABEL_COL = DATASET_SETTING[DATASET]["label_col"]
  
      if DATASET not in ALLOW_DATASET:
          raise AssertionError(
              "The dataset is not supported, please make a new formatter to fit this dataset"
          )
  
      dtrain, dvalid = self._prepare_data(dataset)
      dtrain.loc[:, LABEL_COL] = get_shifted_label(
          dtrain, shifts=LABEL_SHIFT, col_shift=LABEL_COL
      )
      dvalid.loc[:, LABEL_COL] = get_shifted_label(
          dvalid, shifts=LABEL_SHIFT, col_shift=LABEL_COL
      )
  
      train = process_qlib_data(dtrain, DATASET, fillna=True).dropna()
      valid = process_qlib_data(dvalid, DATASET, fillna=True).dropna()
  
      ExperimentConfig = expt_settings.configs.ExperimentConfig
      config = ExperimentConfig(DATASET)
      self.data_formatter = config.make_data_formatter()
      self.model_folder = MODEL_FOLDER
      self.gpu_id = USE_GPU_ID
      self.label_shift = LABEL_SHIFT
      self.expt_name = DATASET
      self.label_col = LABEL_COL
  
      use_gpu = (True, self.gpu_id)
      # ===========================Training Process===========================
      ModelClass = libs.tft_model.TemporalFusionTransformer
      if not isinstance(
          self.data_formatter, data_formatters.base.GenericDataFormatter
      ):
          raise ValueError(
              "Data formatters should inherit from"
              + "AbstractDataFormatter! Type={}".format(
                  type(self.data_formatter)
              )
          )
  
      default_keras_session = tf.keras.backend.get_session()
  
      if use_gpu[0]:
          self.tf_config = utils.get_default_tensorflow_config(
              tf_device="gpu", gpu_id=use_gpu[1]
          )
      else:
          self.tf_config = utils.get_default_tensorflow_config(
              tf_device="cpu"
          )
  
      self.data_formatter.set_scalers(train)
  
      # Sets up default params
      fixed_params = self.data_formatter.get_experiment_params()
      params = self.data_formatter.get_default_model_params()
  
      params = {**params, **fixed_params}
  
      if not os.path.exists(self.model_folder):
          os.makedirs(self.model_folder)
      params["model_folder"] = self.model_folder
  
      print("*** Begin training ***")
      best_loss = np.Inf
  
      tf.reset_default_graph()
  
      self.tf_graph = tf.Graph()
      with self.tf_graph.as_default():
          self.sess = tf.Session(config=self.tf_config)
          tf.keras.backend.set_session(self.sess)
          self.model = ModelClass(params, use_cudnn=use_gpu[0])
          self.sess.run(tf.global_variables_initializer())
          self.model.fit(train_df=train, valid_df=valid)
          print("*** Finished training ***")
          saved_model_dir = self.model_folder + "/" + "saved_model"
          if not os.path.exists(saved_model_dir):
              os.makedirs(saved_model_dir)
          self.model.save(saved_model_dir)
  
          def extract_numerical_data(data):
              """Strips out forecast time and identifier columns."""
              return data[
                  [
                      col
                      for col in data.columns
                      if col not in {"forecast_time", "identifier"}
                  ]
              ]
  
          # p50_loss = utils.numpy_normalised_quantile_loss(
          #    extract_numerical_data(targets), extract_numerical_data(p50_forecast),
          #    0.5)
          # p90_loss = utils.numpy_normalised_quantile_loss(
          #    extract_numerical_data(targets), extract_numerical_data(p90_forecast),
          #    0.9)
          tf.keras.backend.set_session(default_keras_session)
      print("Training completed at {}.".format(dte.datetime.now()))
  
imports: from pathlib import Path
  from typing import Union
  import numpy
  import pandas
  import tensorflow.compat.v1
  import data_formatters.base
  import expt_settings.configs
  import libs.hyperparam_opt
  import libs.tft_model
  import libs.utils
  import os
  import datetime
  from qlib.model.base import ModelFT
  from qlib.data.dataset import DatasetH
  from qlib.data.dataset.handler import DataHandlerLP
label_desc: Use image node_id 3 for calling the TFTModel obj's underlying member method code with example usage: obj.fit(dataset, MODEL_FOLDER, USE_GPU_ID) and returns: data