docstr: Transforms the static covariates of a `series` if `method = 'transform'`, and inverse
  transforms the static covariates of a `series` if `method = 'inverse_transform'`.
docstr_tok: ["Transforms","the","static","covariates","of","a","`","series","`","if","`","method","=","'transform","'","`",",","and","inverse","transforms","the","static","covariates","of","a","`","series","`","if","`","method","=","'inverse_transform","'","`","."]
code: def _transform_static_covs(
      series: TimeSeries,
      fitted_params: Dict[str, Any],
      method: Literal["transform", "inverse_transform"],
  ):
      """
      Transforms the static covariates of a `series` if `method = 'transform'`, and inverse
      transforms the static covariates of a `series` if `method = 'inverse_transform'`.
      """
  
      # Unpack parameters:
      transformer_num = fitted_params["transformer_num"]
      transformer_cat = fitted_params["transformer_cat"]
      mask_num = fitted_params["mask_num"][method]
      mask_cat = fitted_params["mask_cat"][method]
      col_map_cat = fitted_params["col_map_cat"][method]
      n_cat_cols = fitted_params["n_cat_cols"][method]
  
      (
          vals_num,
          vals_cat,
      ) = StaticCovariatesTransformer._extract_static_covs(
          series, mask_num, mask_cat
      )
  
      # Transform static covs:
      tr_out_num, tr_out_cat = None, None
      if mask_num.any():
          tr_out_num = getattr(transformer_num, method)(vals_num)
      if mask_cat.any():
          tr_out_cat = getattr(transformer_cat, method)(vals_cat)
          # sparse one hot encoding to dense array
          if isinstance(tr_out_cat, csr_matrix):
              tr_out_cat = tr_out_cat.toarray()
  
      # quick check if everything is in order
      n_vals_cat_cols = 0 if vals_cat is None else vals_cat.shape[1]
      if (method == "inverse_transform") and (
          n_vals_cat_cols != n_cat_cols
      ):
          raise_log(
              ValueError(
                  f"Expected `{n_cat_cols}` categorical value columns but only encountered `{n_vals_cat_cols}`"
              ),
              logger,
          )
  
      series = StaticCovariatesTransformer._add_back_static_covs(
          series,
          tr_out_num,
          tr_out_cat,
          mask_num,
          mask_cat,
          col_map_cat,
      )
  
      return series
  
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 9 for calling the StaticCovariatesTransformer obj's underlying member method code with example usage: obj._transform_static_covs(series, fitted_params, method) and returns: series