code: def ts_fit(
      series: Union[TimeSeries, Sequence[TimeSeries]],
      params: Mapping[str, Any],
      *args,
      **kwargs,
  ) -> Union[Sequence[float], pd.Series]:
      lmbda, method = (
          params["fixed"]["_lmbda"],
          params["fixed"]["_optim_method"],
      )
      # If `global_fit` is `True`, then `series` will be ` Sequence[TimeSeries]`;
      # otherwise, `series` is a single `TimeSeries`:
      if isinstance(series, TimeSeries):
          series = [series]
      if lmbda is None:
          # Compute optimal lmbda for each dimension of the time series. In this case, the return type is
          # an ndarray and not a Sequence
          vals = np.concatenate(
              [BoxCox.stack_samples(ts) for ts in series], axis=0
          )
          lmbda = np.apply_along_axis(
              boxcox_normmax, axis=0, arr=vals, method=method
          )
  
      elif isinstance(lmbda, Sequence):
          raise_if(
              len(lmbda) != series[0].width,
              "lmbda should have one value per dimension (ie. column or variable) of the time series",
              logger,
          )
      else:
          # Replicate lmbda to match dimensions of the time series
          lmbda = [lmbda] * series[0].width
  
      return lmbda
  
file_path: darts/darts/dataprocessing/transformers/boxcox.py
imports: from typing import Any, Mapping, Optional, Sequence, Union
  import numpy
  import pandas
  from scipy.special import inv_boxcox
  from scipy.stats import boxcox, boxcox_normmax
  from darts.logging import get_logger, raise_if
  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 BoxCox obj's underlying member method code with example usage: obj.ts_fit(series, params) and returns: lmbda