prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [BUG] `numba` related failures on main from `tslearn` `lcss`
  On main, it seems we have the following `numba` related failures:
  
  ```
  During: resolving callee type: type(CPUDispatcher(<function _local_squared_dist at 0x14fc267a0>))
  During: typing of call at /Users/runner/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/tslearn/metrics/dtw_variants.py (1421)
  ```
  
  This is not related to the recent newer `numba` release as we did not upgrade yet.
  
  For test runs with the failures, see here: https://github.com/sktime/sktime/actions/runs/6424459407/job/17445296470?pr=5083
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sktime/dists_kernels/base/adapters/_tslearn.py`
  Content:
  ```
  1 # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
  2 """Implements adapter for tslearn distances and kernels."""
  3 import numpy as np
  4 
  5 __all__ = ["_TslearnPwTrafoAdapter"]
  6 __author__ = ["fkiraly"]
  7 
  8 
  9 def _subset_dict(d, keys):
  10     """Subsets dictionary to keys in iterable keys.
  11 
  12     Parameters
  13     ----------
  14     d : dict
  15         dictionary to subset
  16     keys : iterable
  17         keys to subset to
  18 
  19     Returns
  20     -------
  21     dict
  22         subsetted dictionary
  23     """
  24     return {key: d[key] for key in keys if key in d}
  25 
  26 
  27 class _TslearnPwTrafoAdapter:
  28     """Base adapter mixin for tslearn distances and kernels."""
  29 
  30     _tags = {
  31         "symmetric": False,  # is the transformer symmetric, i.e., t(x,y)=t(y,x) always?
  32         "X_inner_mtype": "df-list",
  33         # which mtype is used internally in _transform?
  34         "fit_is_empty": True,  # is "fit" empty? Yes, for all pairwise transforms
  35         "capability:missing_values": True,  # can estimator handle missing data?
  36         "capability:multivariate": True,  # can estimator handle multivariate data?
  37         "pwtrafo_type": "distance",  # type of pw. transformer, "kernel" or "distance"
  38         "python_dependencies": ["tslearn"],
  39     }
  40 
  41     # parameters to pass to the inner tslearn estimator, list of str
  42     # if None, will pass all of self.get_params()
  43     # otherwise, passes only the parameters in the list of str _inner_params
  44     _inner_params = None
  45 
  46     # controls whether vectorization is applied to the tslearn pwtrafo
  47     # True: the adapted function is cdist-like, it can take Panel data directly
  48     # False: the adapted function takes two time series and needs to be vectorized
  49     _is_cdist = True
  50 
  51     def _get_tslearn_pwtrafo(self):
  52         """Abstract method to get tslearn pwtrafo.
  53 
  54         should import and return tslearn pwtrafo
  55         """
  56         # from tslearn import pwtrafo
  57         #
  58         # return pwtrafo
  59         raise NotImplementedError("abstract method")
  60 
  61     def _eval_tslearn_pwtrafo(self, X, X2=None):
  62         """Evaluate tslearn pwtrafo on two time series.
  63 
  64         The default returns of _get_tslearn_pwtrafo
  65         evaluated at X1, X2 and self.get_params
  66 
  67         Parameters
  68         ----------
  69         X, X2: 2D np.ndarrays of format (n_variables, n_timepoints)
  70             two time series to compute the pairwise transform on
  71 
  72         Returns
  73         -------
  74         float
  75             _get_tslearn_pwtrafo result evaluated at X1, X2, and self.get_params()
  76         """
  77         if X2 is None:
  78             X2 = X
  79 
  80         pwtrafo = self._get_tslearn_pwtrafo()
  81         params = self.get_params()
  82         if self._inner_params is not None:
  83             params = _subset_dict(params, self._inner_params)
  84 
  85         return pwtrafo(X, X2, **params)
  86 
  87     def _coerce_df_list_to_list_of_arr(self, X):
  88         return [df.values for df in X]
  89 
  90     def _eval_tslearn_pwtrafo_vectorized(self, X, X2=None):
  91         """Evaluate tslearn pwtrafo on two time series panels.
  92 
  93         Vectorizes _eval_tslearn_pwtrafo over the first dimensions.
  94 
  95         Parameters
  96         ----------
  97         X, X2: 3D np.ndarrays of format (n_instances n_variables, n_timepoints)
  98             two time series panels to compute the pairwise transform on
  99 
  100         Returns
  101         -------
  102         2D np.ndarray
  103             (i, j)-th entry is _eval_tslearn_pwtrafo(self, X1[i], X2[j])
  104         """
  105         if X2 is None:
  106             X2 = X
  107 
  108         m = len(X)
  109         n = len(X2)
  110         res = np.zeros((m, n))
  111         for i in range(m):
  112             for j in range(n):
  113                 res[i, j] = self._eval_tslearn_pwtrafo(X[i], X2[j])
  114         return res
  115 
  116     def _transform(self, X, X2=None):
  117         """Compute distance/kernel matrix.
  118 
  119             Core logic
  120 
  121         Behaviour: returns pairwise distance/kernel matrix
  122             between samples in X and X2
  123                 if X2 is not passed, is equal to X
  124                 if X/X2 is a pd.DataFrame and contains non-numeric columns,
  125                     these are removed before computation
  126 
  127         Parameters
  128         ----------
  129         X: 3D np.array of shape [num_instances, num_vars, num_time_points]
  130         X2: 3D np.array of shape [num_instances, num_vars, num_time_points], optional
  131             default X2 = X
  132 
  133         Returns
  134         -------
  135         distmat: np.array of shape [n, m]
  136             (i,j)-th entry contains distance/kernel between X[i] and X2[j]
  137         """
  138         if isinstance(X, list):
  139             X = self._coerce_df_list_to_list_of_arr(X)
  140         if isinstance(X2, list):
  141             X2 = self._coerce_df_list_to_list_of_arr(X2)
  142 
  143         return self._eval_tslearn_pwtrafo(X, X2)
  144
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sktime/dists_kernels/base/adapters/_tslearn.py b/sktime/dists_kernels/base/adapters/_tslearn.py
  --- a/sktime/dists_kernels/base/adapters/_tslearn.py
  +++ b/sktime/dists_kernels/base/adapters/_tslearn.py
  @@ -140,4 +140,7 @@
           if isinstance(X2, list):
               X2 = self._coerce_df_list_to_list_of_arr(X2)
   
  -        return self._eval_tslearn_pwtrafo(X, X2)
  +        if self._is_cdist:
  +            return self._eval_tslearn_pwtrafo(X, X2)
  +        else:
  +            return self._eval_tslearn_pwtrafo_vectorized(X, X2)
  
verification_info: {"golden_diff": "diff --git a/sktime/dists_kernels/base/adapters/_tslearn.py b/sktime/dists_kernels/base/adapters/_tslearn.py\n--- a/sktime/dists_kernels/base/adapters/_tslearn.py\n+++ b/sktime/dists_kernels/base/adapters/_tslearn.py\n@@ -140,4 +140,7 @@\n         if isinstance(X2, list):\n             X2 = self._coerce_df_list_to_list_of_arr(X2)\n \n-        return self._eval_tslearn_pwtrafo(X, X2)\n+        if self._is_cdist:\n+            return self._eval_tslearn_pwtrafo(X, X2)\n+        else:\n+            return self._eval_tslearn_pwtrafo_vectorized(X, X2)\n", "issue": "[BUG] `numba` related failures on main from `tslearn` `lcss`\nOn main, it seems we have the following `numba` related failures:\r\n\r\n```\r\nDuring: resolving callee type: type(CPUDispatcher(<function _local_squared_dist at 0x14fc267a0>))\r\nDuring: typing of call at /Users/runner/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/tslearn/metrics/dtw_variants.py (1421)\r\n```\r\n\r\nThis is not related to the recent newer `numba` release as we did not upgrade yet.\r\n\r\nFor test runs with the failures, see here: https://github.com/sktime/sktime/actions/runs/6424459407/job/17445296470?pr=5083\r\n\n", "before_files": [{"content": "# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\"\"\"Implements adapter for tslearn distances and kernels.\"\"\"\nimport numpy as np\n\n__all__ = [\"_TslearnPwTrafoAdapter\"]\n__author__ = [\"fkiraly\"]\n\n\ndef _subset_dict(d, keys):\n    \"\"\"Subsets dictionary to keys in iterable keys.\n\n    Parameters\n    ----------\n    d : dict\n        dictionary to subset\n    keys : iterable\n        keys to subset to\n\n    Returns\n    -------\n    dict\n        subsetted dictionary\n    \"\"\"\n    return {key: d[key] for key in keys if key in d}\n\n\nclass _TslearnPwTrafoAdapter:\n    \"\"\"Base adapter mixin for tslearn distances and kernels.\"\"\"\n\n    _tags = {\n        \"symmetric\": False,  # is the transformer symmetric, i.e., t(x,y)=t(y,x) always?\n        \"X_inner_mtype\": \"df-list\",\n        # which mtype is used internally in _transform?\n        \"fit_is_empty\": True,  # is \"fit\" empty? Yes, for all pairwise transforms\n        \"capability:missing_values\": True,  # can estimator handle missing data?\n        \"capability:multivariate\": True,  # can estimator handle multivariate data?\n        \"pwtrafo_type\": \"distance\",  # type of pw. transformer, \"kernel\" or \"distance\"\n        \"python_dependencies\": [\"tslearn\"],\n    }\n\n    # parameters to pass to the inner tslearn estimator, list of str\n    # if None, will pass all of self.get_params()\n    # otherwise, passes only the parameters in the list of str _inner_params\n    _inner_params = None\n\n    # controls whether vectorization is applied to the tslearn pwtrafo\n    # True: the adapted function is cdist-like, it can take Panel data directly\n    # False: the adapted function takes two time series and needs to be vectorized\n    _is_cdist = True\n\n    def _get_tslearn_pwtrafo(self):\n        \"\"\"Abstract method to get tslearn pwtrafo.\n\n        should import and return tslearn pwtrafo\n        \"\"\"\n        # from tslearn import pwtrafo\n        #\n        # return pwtrafo\n        raise NotImplementedError(\"abstract method\")\n\n    def _eval_tslearn_pwtrafo(self, X, X2=None):\n        \"\"\"Evaluate tslearn pwtrafo on two time series.\n\n        The default returns of _get_tslearn_pwtrafo\n        evaluated at X1, X2 and self.get_params\n\n        Parameters\n        ----------\n        X, X2: 2D np.ndarrays of format (n_variables, n_timepoints)\n            two time series to compute the pairwise transform on\n\n        Returns\n        -------\n        float\n            _get_tslearn_pwtrafo result evaluated at X1, X2, and self.get_params()\n        \"\"\"\n        if X2 is None:\n            X2 = X\n\n        pwtrafo = self._get_tslearn_pwtrafo()\n        params = self.get_params()\n        if self._inner_params is not None:\n            params = _subset_dict(params, self._inner_params)\n\n        return pwtrafo(X, X2, **params)\n\n    def _coerce_df_list_to_list_of_arr(self, X):\n        return [df.values for df in X]\n\n    def _eval_tslearn_pwtrafo_vectorized(self, X, X2=None):\n        \"\"\"Evaluate tslearn pwtrafo on two time series panels.\n\n        Vectorizes _eval_tslearn_pwtrafo over the first dimensions.\n\n        Parameters\n        ----------\n        X, X2: 3D np.ndarrays of format (n_instances n_variables, n_timepoints)\n            two time series panels to compute the pairwise transform on\n\n        Returns\n        -------\n        2D np.ndarray\n            (i, j)-th entry is _eval_tslearn_pwtrafo(self, X1[i], X2[j])\n        \"\"\"\n        if X2 is None:\n            X2 = X\n\n        m = len(X)\n        n = len(X2)\n        res = np.zeros((m, n))\n        for i in range(m):\n            for j in range(n):\n                res[i, j] = self._eval_tslearn_pwtrafo(X[i], X2[j])\n        return res\n\n    def _transform(self, X, X2=None):\n        \"\"\"Compute distance/kernel matrix.\n\n            Core logic\n\n        Behaviour: returns pairwise distance/kernel matrix\n            between samples in X and X2\n                if X2 is not passed, is equal to X\n                if X/X2 is a pd.DataFrame and contains non-numeric columns,\n                    these are removed before computation\n\n        Parameters\n        ----------\n        X: 3D np.array of shape [num_instances, num_vars, num_time_points]\n        X2: 3D np.array of shape [num_instances, num_vars, num_time_points], optional\n            default X2 = X\n\n        Returns\n        -------\n        distmat: np.array of shape [n, m]\n            (i,j)-th entry contains distance/kernel between X[i] and X2[j]\n        \"\"\"\n        if isinstance(X, list):\n            X = self._coerce_df_list_to_list_of_arr(X)\n        if isinstance(X2, list):\n            X2 = self._coerce_df_list_to_list_of_arr(X2)\n\n        return self._eval_tslearn_pwtrafo(X, X2)\n", "path": "sktime/dists_kernels/base/adapters/_tslearn.py"}], "after_files": [{"content": "# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\"\"\"Implements adapter for tslearn distances and kernels.\"\"\"\nimport numpy as np\n\n__all__ = [\"_TslearnPwTrafoAdapter\"]\n__author__ = [\"fkiraly\"]\n\n\ndef _subset_dict(d, keys):\n    \"\"\"Subsets dictionary to keys in iterable keys.\n\n    Parameters\n    ----------\n    d : dict\n        dictionary to subset\n    keys : iterable\n        keys to subset to\n\n    Returns\n    -------\n    dict\n        subsetted dictionary\n    \"\"\"\n    return {key: d[key] for key in keys if key in d}\n\n\nclass _TslearnPwTrafoAdapter:\n    \"\"\"Base adapter mixin for tslearn distances and kernels.\"\"\"\n\n    _tags = {\n        \"symmetric\": False,  # is the transformer symmetric, i.e., t(x,y)=t(y,x) always?\n        \"X_inner_mtype\": \"df-list\",\n        # which mtype is used internally in _transform?\n        \"fit_is_empty\": True,  # is \"fit\" empty? Yes, for all pairwise transforms\n        \"capability:missing_values\": True,  # can estimator handle missing data?\n        \"capability:multivariate\": True,  # can estimator handle multivariate data?\n        \"pwtrafo_type\": \"distance\",  # type of pw. transformer, \"kernel\" or \"distance\"\n        \"python_dependencies\": [\"tslearn\"],\n    }\n\n    # parameters to pass to the inner tslearn estimator, list of str\n    # if None, will pass all of self.get_params()\n    # otherwise, passes only the parameters in the list of str _inner_params\n    _inner_params = None\n\n    # controls whether vectorization is applied to the tslearn pwtrafo\n    # True: the adapted function is cdist-like, it can take Panel data directly\n    # False: the adapted function takes two time series and needs to be vectorized\n    _is_cdist = True\n\n    def _get_tslearn_pwtrafo(self):\n        \"\"\"Abstract method to get tslearn pwtrafo.\n\n        should import and return tslearn pwtrafo\n        \"\"\"\n        # from tslearn import pwtrafo\n        #\n        # return pwtrafo\n        raise NotImplementedError(\"abstract method\")\n\n    def _eval_tslearn_pwtrafo(self, X, X2=None):\n        \"\"\"Evaluate tslearn pwtrafo on two time series.\n\n        The default returns of _get_tslearn_pwtrafo\n        evaluated at X1, X2 and self.get_params\n\n        Parameters\n        ----------\n        X, X2: 2D np.ndarrays of format (n_variables, n_timepoints)\n            two time series to compute the pairwise transform on\n\n        Returns\n        -------\n        float\n            _get_tslearn_pwtrafo result evaluated at X1, X2, and self.get_params()\n        \"\"\"\n        if X2 is None:\n            X2 = X\n\n        pwtrafo = self._get_tslearn_pwtrafo()\n        params = self.get_params()\n        if self._inner_params is not None:\n            params = _subset_dict(params, self._inner_params)\n\n        return pwtrafo(X, X2, **params)\n\n    def _coerce_df_list_to_list_of_arr(self, X):\n        return [df.values for df in X]\n\n    def _eval_tslearn_pwtrafo_vectorized(self, X, X2=None):\n        \"\"\"Evaluate tslearn pwtrafo on two time series panels.\n\n        Vectorizes _eval_tslearn_pwtrafo over the first dimensions.\n\n        Parameters\n        ----------\n        X, X2: 3D np.ndarrays of format (n_instances n_variables, n_timepoints)\n            two time series panels to compute the pairwise transform on\n\n        Returns\n        -------\n        2D np.ndarray\n            (i, j)-th entry is _eval_tslearn_pwtrafo(self, X1[i], X2[j])\n        \"\"\"\n        if X2 is None:\n            X2 = X\n\n        m = len(X)\n        n = len(X2)\n        res = np.zeros((m, n))\n        for i in range(m):\n            for j in range(n):\n                res[i, j] = self._eval_tslearn_pwtrafo(X[i], X2[j])\n        return res\n\n    def _transform(self, X, X2=None):\n        \"\"\"Compute distance/kernel matrix.\n\n            Core logic\n\n        Behaviour: returns pairwise distance/kernel matrix\n            between samples in X and X2\n                if X2 is not passed, is equal to X\n                if X/X2 is a pd.DataFrame and contains non-numeric columns,\n                    these are removed before computation\n\n        Parameters\n        ----------\n        X: 3D np.array of shape [num_instances, num_vars, num_time_points]\n        X2: 3D np.array of shape [num_instances, num_vars, num_time_points], optional\n            default X2 = X\n\n        Returns\n        -------\n        distmat: np.array of shape [n, m]\n            (i,j)-th entry contains distance/kernel between X[i] and X2[j]\n        \"\"\"\n        if isinstance(X, list):\n            X = self._coerce_df_list_to_list_of_arr(X)\n        if isinstance(X2, list):\n            X2 = self._coerce_df_list_to_list_of_arr(X2)\n\n        if self._is_cdist:\n            return self._eval_tslearn_pwtrafo(X, X2)\n        else:\n            return self._eval_tslearn_pwtrafo_vectorized(X, X2)\n", "path": "sktime/dists_kernels/base/adapters/_tslearn.py"}]}