code: def _with_sanity_checks(
      *sanity_check_methods: str,
  ) -> Callable[[Callable[[A, B], T]], Callable[[A, B], T]]:
      """
      Decorator allowing to specify some sanity check method(s) to be used on a class method.
      The decorator guarantees that args and kwargs from the method to sanitize will be available in the
      sanity check methods as specified in the sanitized method's signature, irrespective of how it was called.
  
      Parameters
      ----------
      *sanity_check_methods
          one or more sanity check methods that will be called with all the parameter of the decorated method.
  
      Returns
      -------
      A Callable corresponding to the decorated method.
  
      Examples
      --------
      class Model:
          def _a_sanity_check(self, *args, **kwargs):
              raise_if_not(kwargs['b'] == kwargs['c'], 'b must equal c', logger)
          @_with_sanity_checks("_a_sanity_check")
          def fit(self, a, b=0, c=0):
              # at this point we can safely assume that 'b' and 'c' are equal...
              ...
      """
  
      def decorator(
          method_to_sanitize: Callable[[A, B], T]
      ) -> Callable[[A, B], T]:
          @wraps(method_to_sanitize)
          def sanitized_method(self, *args: A, **kwargs: B) -> T:
              for sanity_check_method in sanity_check_methods:
                  # Convert all arguments into keyword arguments
                  all_as_kwargs = getcallargs(
                      method_to_sanitize, self, *args, **kwargs
                  )
  
                  # Then separate args from kwargs according to the function's signature
                  only_args = all_as_kwargs.copy()
                  only_kwargs = all_as_kwargs.copy()
  
                  for param_name, param in signature(
                      method_to_sanitize
                  ).parameters.items():
                      if (
                          param.default == Parameter.empty
                          and param.kind != Parameter.VAR_POSITIONAL
                      ):
                          only_kwargs.pop(param_name)
                      else:
                          only_args.pop(param_name)
  
                  only_args.pop("self")
  
                  getattr(self, sanity_check_method)(
                      *only_args.values(), **only_kwargs
                  )
              return method_to_sanitize(
                  self, *only_args.values(), **only_kwargs
              )
  
          return sanitized_method
  
      return decorator
  
imports: from enum import Enum
  from functools import wraps
  from inspect import Parameter, getcallargs, signature
  from typing import Callable, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union
  import pandas
  from joblib import Parallel, delayed
  from tqdm import tqdm
  from tqdm.notebook import tqdm
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.utils.timeseries_generation import generate_index
label_desc: Use image node_id 3 for calling a global function with example usage: _with_sanity_checks() and returns: decorator, sanitized_method, method_to_sanitize