class_docstr: Dynamic Time Warping (DTW) Alignment.
  
  Attributes
  ----------
  n
      The length of `series1`
  m
      The length of `series2`
  series1
      A `TimeSeries` to align with `series2`.
  series2
      A `TimeSeries` to align with `series1`.
  cost
      The `CostMatrix` for DTW.
class_docstr_tok: ["Dynamic","Time","Warping","(","DTW",")","Alignment",".","Attributes","--","--","--","--","--","n","The","length","of","`","series1","`","m","The","length","of","`","series2","`","series1","A","`","TimeSeries","`","to","align","with","`","series2","`",".","series2","A","`","TimeSeries","`","to","align","with","`","series1","`",".","cost","The","`","CostMatrix","`","for","DTW","."]
docstr: Warps the two time series according to the warp path returned by `DTWAlignment.path()`, which minimizes the
  pair-wise distance.
  This will bring two time series that are out-of-phase back into phase.
  
  Returns
  -------
  (TimeSeries, TimeSeries)
      Two new TimeSeries instances of the same length, indexed by pd.RangeIndex.
docstr_tok: ["Warps","the","two","time","series","according","to","the","warp","path","returned","by","`","DTWAlignment.path","(",")","`",",","which","minimizes","the","pair-wise","distance",".","This","will","bring","two","time","series","that","are","out-of-phase","back","into","phase",".","Returns","--","--","--","-","(","TimeSeries",",","TimeSeries",")","Two","new","TimeSeries","instances","of","the","same","length",",","indexed","by","pd.RangeIndex","."]
code: def warped(self) -> (TimeSeries, TimeSeries):
      """Warps the two time series according to the warp path returned by `DTWAlignment.path()`, which minimizes the
      pair-wise distance.
      This will bring two time series that are out-of-phase back into phase.
  
      Returns
      -------
      (TimeSeries, TimeSeries)
          Two new TimeSeries instances of the same length, indexed by pd.RangeIndex.
      """
  
      xa1 = self.series1.data_array(copy=False)
      xa2 = self.series2.data_array(copy=False)
      path = self.path()
  
      values1, values2 = xa1.values[path[:, 0]], xa2.values[path[:, 1]]
  
      # We set a RangeIndex for both series:
      warped_series1 = xr.DataArray(
          data=values1,
          dims=xa1.dims,
          coords={
              self.series1._time_dim: pd.RangeIndex(values1.shape[0]),
              DIMS[1]: xa1.coords[DIMS[1]],
          },
          attrs=xa1.attrs,
      )
  
      warped_series2 = xr.DataArray(
          data=values2,
          dims=xa2.dims,
          coords={
              self.series2._time_dim: pd.RangeIndex(values2.shape[0]),
              DIMS[1]: xa2.coords[DIMS[1]],
          },
          attrs=xa2.attrs,
      )
  
      time_dim1, time_dim2 = (
          self.series1._time_dim,
          self.series2._time_dim,
      )
  
      # todo: prevent time information being lost after warping
      # Applying time index from series1 to series2 (take_dates = True) is disabled for consistency reasons
      # Applying the warp path to the dates directly will result in duplicate dates
      # and hence values being lost when converting back to a TimeSeries.
      # As a result series1 will not be warped, whereas series2 will be.
      # It could also cause the two series to have different lengths, if len(series1) < len(series2)
      # One could generate intermediate dates, but then the series would not have a consistent frequency
  
      take_dates = False
      if take_dates:
          time_index = warped_series1[time_dim1]
          time_index = time_index.rename({time_dim1: time_dim2})
          warped_series2[time_dim2] = time_index
  
      return TimeSeries.from_xarray(
          warped_series1
      ), TimeSeries.from_xarray(warped_series2)
  
imports: import copy
  from typing import Callable, Optional, Union
  import numpy
  import pandas
  import xarray
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if, raise_if_not
  from darts.timeseries import DIMS
  from .cost_matrix import CostMatrix
  from .window import CRWindow, NoWindow, Window
label_desc: Use image node_id 5 for calling the DTWAlignment obj's underlying member method code with example usage: obj.warped() and returns: TimeSeries,  TimeSeries