def METHOD_NAME(
    X: np.ndarray,
    metric: str = "dtw",
    max_iters: int = 30,
    tol=1e-5,
    precomputed_medoids_pairwise_distance: np.ndarray = None,
    verbose: bool = False,
    **kwargs,
) -> np.ndarray:
    """Compute the barycenter average of time series using a elastic distance.
    This implements an adapted version of 'petitjean' (original) DBA algorithm [1]_.
    Parameters
    ----------
    X: np.ndarray, of shape (n_instances, n_channels, n_timepoints) or
            (n_instances, n_timepoints)
        A collection of time series instances to take the average from.
    metric: str or Callable, default='dtw'
        String defining the distance metric to use for averaging. Distance metric to
        compute similarity between time series. A list of valid strings for metrics
        can be found in the documentation form
        :func:`aeon.distances.get_distance_function`.
        If Callable provided must be of the form (x, y) -> (float, np.ndarray)
        where the first element is the distance and the second is the alignment path.
    max_iters: int, default=30
        Maximum number iterations for dba to update over.
    tol : float (default: 1e-5)
        Tolerance to use for early stopping: if the decrease in cost is lower
        than this value, the Expectation-Maximization procedure stops.
    precomputed_medoids_pairwise_distance: np.ndarray (of shape (len(X), len(X)),
                default=None
        Precomputed medoids pairwise.
    verbose: bool, default=False
        Boolean that controls the verbosity.
    **kwargs
        Keyword arguments to pass to the distance metric.
    Returns
    -------
    np.ndarray of shape (n_channels, n_timepoints)
        Time series that is the average of the collection of instances provided.
    References
    ----------
    .. [1] F. Petitjean, A. Ketterlin & P. Gancarski. A global averaging method
       for dynamic time warping, with applications to clustering. Pattern
       Recognition, Elsevier, 2011, Vol. 44, Num. 3, pp. 678-693
    """
    if len(X) <= 1:
        return X
    # center = X.mean(axis=0)
    center = medoids(
        X,
        distance_metric=metric,
        precomputed_pairwise_distance=precomputed_medoids_pairwise_distance,
        **kwargs,
    )
    cost_prev = np.inf
    if metric == "wdtw" or metric == "wddtw":
        if "g" not in kwargs:
            kwargs["g"] = 0.05
    for i in range(max_iters):
        center, cost = _ba_update(center, X, metric, **kwargs)
        if abs(cost_prev - cost) < tol:
            break
        elif cost_prev < cost:
            break
        else:
            cost_prev = cost
        if verbose:
            print(f"[DBA aeon] epoch {i}, cost {cost}")  # noqa: T001, T201
    return center