docstr: Scale the time series dataset's feature column and target column.
  
  :param scaler: a dictionary of scaler instance, where keys are id name
         and values are corresponding scaler instance. e.g. if you have
         2 ids called "id1" and "id2", a legal scaler input can be
         {"id1": StandardScaler(), "id2": StandardScaler()}
  :param fit: if we need to fit the scaler. Typically, the value should
         be set to True for training set, while False for validation and
         test set. The value is defaulted to True.
  
  :return: the xshardtsdataset instance.
  
  Assume there is a training set tsdata and a test set tsdata_test.
  scale() should be called first on training set with default value fit=True,
  then be called on test set with the same scaler and fit=False.
  
  >>> from sklearn.preprocessing import StandardScaler
  >>> scaler = {"id1": StandardScaler(), "id2": StandardScaler()}
  >>> tsdata.scale(scaler, fit=True)
  >>> tsdata_test.scale(scaler, fit=False)
docstr_tok: ["Scale","the","time","series","dataset","'s","feature","column","and","target","column",".",":","param","scaler",":","a","dictionary","of","scaler","instance",",","where","keys","are","id","name","and","values","are","corresponding","scaler","instance",".","e.g",".","if","you","have","2","ids","called","``","id1","''","and","``","id2","''",",","a","legal","scaler","input","can","be","{","``","id1","''",":","StandardScaler","(",")",",","``","id2","''",":","StandardScaler","(",")","}",":","param","fit",":","if","we","need","to","fit","the","scaler",".","Typically",",","the","value","should","be","set","to","True","for","training","set",",","while","False","for","validation","and","test","set",".","The","value","is","defaulted","to","True",".",":","return",":","the","xshardtsdataset","instance",".","Assume","there","is","a","training","set","tsdata","and","a","test","set","tsdata_test",".","scale","(",")","should","be","called","first","on","training","set","with","default","value","fit=True",",","then","be","called","on","test","set","with","the","same","scaler","and","fit=False",".",">",">",">","from","sklearn.preprocessing","import","StandardScaler",">",">",">","scaler","=","{","``","id1","''",":","StandardScaler","(",")",",","``","id2","''",":","StandardScaler","(",")","}",">",">",">","tsdata.scale","(","scaler",",","fit=True",")",">",">",">","tsdata_test.scale","(","scaler",",","fit=False",")"]
code: def scale(self, scaler, fit=True):
      """
      Scale the time series dataset's feature column and target column.
  
      :param scaler: a dictionary of scaler instance, where keys are id name
             and values are corresponding scaler instance. e.g. if you have
             2 ids called "id1" and "id2", a legal scaler input can be
             {"id1": StandardScaler(), "id2": StandardScaler()}
      :param fit: if we need to fit the scaler. Typically, the value should
             be set to True for training set, while False for validation and
             test set. The value is defaulted to True.
  
      :return: the xshardtsdataset instance.
  
      Assume there is a training set tsdata and a test set tsdata_test.
      scale() should be called first on training set with default value fit=True,
      then be called on test set with the same scaler and fit=False.
  
      >>> from sklearn.preprocessing import StandardScaler
      >>> scaler = {"id1": StandardScaler(), "id2": StandardScaler()}
      >>> tsdata.scale(scaler, fit=True)
      >>> tsdata_test.scale(scaler, fit=False)
      """
  
      def _fit(df, id_col, scaler, feature_col, target_col):
          """
          This function is used to fit scaler dictionary on each shard.
          returns a dictionary of id-scaler pair for each shard.
  
          Note: this function will not transform the shard.
          """
          scaler_for_this_id = scaler[df[id_col].iloc[0]]
          df[target_col + feature_col] = scaler_for_this_id.fit(
              df[target_col + feature_col]
          )
  
          return {
              id_col: df[id_col].iloc[0],
              "scaler": scaler_for_this_id,
          }
  
      def _transform(df, id_col, scaler, feature_col, target_col):
          """
          This function is used to transform the shard by fitted scaler.
  
          Note: this function will not fit the scaler.
          """
          from sklearn.utils.validation import check_is_fitted
          from bigdl.nano.utils.common import invalidInputError
  
          scaler_for_this_id = scaler[df[id_col].iloc[0]]
          invalidInputError(
              not check_is_fitted(scaler_for_this_id),
              "scaler is not fitted. When calling scale for the first time, "
              "you need to set fit=True.",
          )
          df[target_col + feature_col] = scaler_for_this_id.transform(
              df[target_col + feature_col]
          )
  
          return df
  
      if fit:
          self.shards_scaler = self.shards.transform_shard(
              _fit,
              self.id_col,
              scaler,
              self.feature_col,
              self.target_col,
          )
          self.scaler_dict = self.shards_scaler.collect()
          self.scaler_dict = {
              sc[self.id_col]: sc["scaler"] for sc in self.scaler_dict
          }
          scaler.update(
              self.scaler_dict
          )  # make the change up-to-date outside the tsdata
  
          self.shards = self.shards.transform_shard(
              _transform,
              self.id_col,
              self.scaler_dict,
              self.feature_col,
              self.target_col,
          )
      else:
          self.scaler_dict = scaler
          self.shards = self.shards.transform_shard(
              _transform,
              self.id_col,
              self.scaler_dict,
              self.feature_col,
              self.target_col,
          )
      return self
  
imports: from bigdl.orca.data.shard import SparkXShards
  from bigdl.orca.learn.utils import dataframe_to_xshards_of_pandas_df
  from bigdl.chronos.data.utils.utils import _to_list, _check_type
  from bigdl.chronos.data.utils.roll import roll_timeseries_dataframe
  from bigdl.chronos.data.utils.impute import impute_timeseries_dataframe
  from bigdl.chronos.data.utils.split import split_timeseries_dataframe
  from bigdl.chronos.data.experimental.utils import add_row, transform_to_dict
  from bigdl.chronos.data.utils.scale import unscale_timeseries_numpy
  from bigdl.chronos.data.utils.feature import generate_dt_features
  import pandas
label_desc: Use image node_id 5 for calling the XShardsTSDataset obj's underlying member method code with example usage: obj.scale(scaler, fit) and returns: self, dict, df