docstr: Collates static covariates of all provided `TimeSeries` and fits the following parameters:
      1. `transformer_num`, the fitted numerical static covariate transformer.
      2. `transformer_cat`, the fitted categorical static covariate transformer.
      3. `mask_num`, a dictionary containing two boolean arrays: one that indicates which
      components of the *untransformed* static covariates are numerical, and another that
      indicates which components of the *transformed* static covariates are numerical.
      4. `mask_cat`, a dictionary containing two boolean arrays: one that indicates which
      components of the *untransformed* static covariates are categorical, and another that
      indicates which components of the *transformed* static covariates are categorical.
      5. `n_cat_cols`, a dictionary that stores the number of categorical columns
      we should expect in the untransformed and in the transformed static covariates.
docstr_tok: ["Collates","static","covariates","of","all","provided","`","TimeSeries","`","and","fits","the","following","parameters",":","1",".","`","transformer_num","`",",","the","fitted","numerical","static","covariate","transformer",".","2",".","`","transformer_cat","`",",","the","fitted","categorical","static","covariate","transformer",".","3",".","`","mask_num","`",",","a","dictionary","containing","two","boolean","arrays",":","one","that","indicates","which","components","of","the","*","untransformed","*","static","covariates","are","numerical",",","and","another","that","indicates","which","components","of","the","*","transformed","*","static","covariates","are","numerical",".","4",".","`","mask_cat","`",",","a","dictionary","containing","two","boolean","arrays",":","one","that","indicates","which","components","of","the","*","untransformed","*","static","covariates","are","categorical",",","and","another","that","indicates","which","components","of","the","*","transformed","*","static","covariates","are","categorical",".","5",".","`","n_cat_cols","`",",","a","dictionary","that","stores","the","number","of","categorical","columns","we","should","expect","in","the","untransformed","and","in","the","transformed","static","covariates","."]
code: def ts_fit(
      series: Sequence[TimeSeries],
      params: Dict[str, Dict[str, Any]],
      *args,
      **kwargs,
  ):
      """
      Collates static covariates of all provided `TimeSeries` and fits the following parameters:
          1. `transformer_num`, the fitted numerical static covariate transformer.
          2. `transformer_cat`, the fitted categorical static covariate transformer.
          3. `mask_num`, a dictionary containing two boolean arrays: one that indicates which
          components of the *untransformed* static covariates are numerical, and another that
          indicates which components of the *transformed* static covariates are numerical.
          4. `mask_cat`, a dictionary containing two boolean arrays: one that indicates which
          components of the *untransformed* static covariates are categorical, and another that
          indicates which components of the *transformed* static covariates are categorical.
          5. `n_cat_cols`, a dictionary that stores the number of categorical columns
          we should expect in the untransformed and in the transformed static covariates.
      """
  
      fixed_params = params["fixed"]
      transformer_num = fixed_params["transformer_num"]
      transformer_cat = fixed_params["transformer_cat"]
      cols_num = fixed_params["cols_num"]
      cols_cat = fixed_params["cols_cat"]
  
      # Collate static covariates of all `series`:
      stat_covs = pd.concat(
          [s.static_covariates for s in series], axis=0
      )
  
      (
          cols_num,
          cols_cat,
      ) = StaticCovariatesTransformer._infer_static_cov_dtypes(
          stat_covs, cols_num, cols_cat
      )
  
      (
          mask_num,
          mask_cat,
      ) = StaticCovariatesTransformer._create_component_masks(
          stat_covs, cols_num, cols_cat
      )
  
      # Fit numerical and categorical static covariate transformers:
      stat_covs = stat_covs.to_numpy(copy=False)
      if mask_num.any():
          transformer_num = transformer_num.fit(stat_covs[:, mask_num])
      if mask_cat.any():
          transformer_cat = transformer_cat.fit(stat_covs[:, mask_cat])
  
      (
          cat_mapping,
          inv_cat_mapping,
      ) = StaticCovariatesTransformer._create_category_mappings(
          stat_covs, transformer_cat, mask_cat, cols_cat
      )
  
      (
          inv_mask_num,
          inv_mask_cat,
      ) = StaticCovariatesTransformer._create_inv_component_masks(
          mask_num, mask_cat, cat_mapping, cols_cat
      )
  
      # Store masks and category mappings for untransformed and transformed static covariates:
      mask_num_dict = {
          "transform": mask_num,
          "inverse_transform": inv_mask_num,
      }
      mask_cat_dict = {
          "transform": mask_cat,
          "inverse_transform": inv_mask_cat,
      }
      col_map_cat_dict = {
          "transform": cat_mapping,
          "inverse_transform": inv_cat_mapping,
      }
      # Count number of categorical features in untransformed and transformed static covariates:
      n_cat_cols = {
          method: len(col_map_cat_dict[method])
          for method in ("transform", "inverse_transform")
      }
  
      return {
          "transformer_num": transformer_num,
          "transformer_cat": transformer_cat,
          "mask_num": mask_num_dict,
          "mask_cat": mask_cat_dict,
          "col_map_cat": col_map_cat_dict,
          "n_cat_cols": n_cat_cols,
      }
  
imports: from collections import OrderedDict
  from typing import Any, Dict, List, Optional, Sequence, Tuple
  import numpy
  import pandas
  from scipy.sparse import csr_matrix
  from sklearn.preprocessing import MinMaxScaler, OrdinalEncoder
  from darts.logging import get_logger, raise_log
  from darts.timeseries import TimeSeries
  from .fittable_data_transformer import FittableDataTransformer
  from .invertible_data_transformer import InvertibleDataTransformer
label_desc: Use image node_id 2 for calling the StaticCovariatesTransformer obj's underlying member method code with example usage: obj.ts_fit(series, params) and returns: dict