code: def initialize_weights(
      forecaster_name: str,
      regressor: object,
      weight_func: Union[Callable, dict],
      series_weights: dict,
  ) -> Tuple[Union[Callable, dict], Union[str, dict], dict]:
      """
      Check weights arguments, `weight_func` and `series_weights` for the different
      forecasters. Create `source_code_weight_func`, source code of the custom
      function(s) used to create weights.
  
      Parameters
      ----------
      forecaster_name : str
          Forecaster name. ForecasterAutoreg, ForecasterAutoregCustom,
          ForecasterAutoregDirect, ForecasterAutoregMultiSeries,
          ForecasterAutoregMultiSeriesCustom, ForecasterAutoregMultiVariate.
      regressor : regressor or pipeline compatible with the scikit-learn API
          Regressor of the forecaster.
      weight_func : Callable, dict
          Argument `weight_func` of the forecaster.
      series_weights : dict
          Argument `series_weights` of the forecaster.
  
      Returns
      -------
      weight_func : Callable, dict
          Argument `weight_func` of the forecaster.
      source_code_weight_func : str, dict
          Argument `source_code_weight_func` of the forecaster.
      series_weights : dict
          Argument `series_weights` of the forecaster.
  
      """
  
      source_code_weight_func = None
  
      if weight_func is not None:
          if forecaster_name in [
              "ForecasterAutoregMultiSeries",
              "ForecasterAutoregMultiSeriesCustom",
          ]:
              if not isinstance(weight_func, (Callable, dict)):
                  raise TypeError(
                      (
                          f"Argument `weight_func` must be a Callable or a dict of "
                          f"Callables. Got {type(weight_func)}."
                      )
                  )
          elif not isinstance(weight_func, Callable):
              raise TypeError(
                  f"Argument `weight_func` must be a Callable. Got {type(weight_func)}."
              )
  
          if isinstance(weight_func, dict):
              source_code_weight_func = {}
              for key in weight_func:
                  source_code_weight_func[key] = inspect.getsource(
                      weight_func[key]
                  )
          else:
              source_code_weight_func = inspect.getsource(weight_func)
  
          if (
              "sample_weight"
              not in inspect.signature(regressor.fit).parameters
          ):
              warnings.warn(
                  (
                      f"Argument `weight_func` is ignored since regressor {regressor} "
                      f"does not accept `sample_weight` in its `fit` method."
                  ),
                  IgnoredArgumentWarning,
              )
              weight_func = None
              source_code_weight_func = None
  
      if series_weights is not None:
          if not isinstance(series_weights, dict):
              raise TypeError(
                  (
                      f"Argument `series_weights` must be a dict of floats or ints."
                      f"Got {type(series_weights)}."
                  )
              )
          if (
              "sample_weight"
              not in inspect.signature(regressor.fit).parameters
          ):
              warnings.warn(
                  (
                      f"Argument `series_weights` is ignored since regressor {regressor} "
                      f"does not accept `sample_weight` in its `fit` method."
                  ),
                  IgnoredArgumentWarning,
              )
              series_weights = None
  
      return weight_func, source_code_weight_func, series_weights
  
imports: from typing import Union, Any, Optional, Tuple, Callable
  import warnings
  import importlib
  import joblib
  import numpy
  import pandas
  import sklearn
  import sklearn.pipeline
  import sklearn.linear_model
  from sklearn.compose import ColumnTransformer
  from sklearn.exceptions import NotFittedError
  import inspect
  from copy import deepcopy
  import skforecast
  from ..exceptions import MissingValuesExogWarning
  from ..exceptions import DataTypeWarning
  from ..exceptions import IgnoredArgumentWarning
  from ..exceptions import SkforecastVersionWarning
label_desc: Use image node_id 2 for calling a global function with example usage: initialize_weights(forecaster_name, regressor, weight_func, series_weights) and returns: weight_func,  source_code_weight_func,  series_weights