code: def _get_matching_index(
      ts_target: TimeSeries, ts_covariate: TimeSeries, idx: int
  ):
      """
      Given two overlapping series `ts_target` and `ts_covariate` and an index point `idx` of `ts_target`, returns the
      matching index point in `ts_covariate`, based on the ending times of the two series.
      The indices are starting from the end of the series.
  
      This function is used to jointly slice target and covariate series in datasets. It supports both datetime and
      integer indexed series.
  
      Note: this function does not check if the matching index value is in `ts_covariate` or not.
      """
      raise_if_not(
          ts_target.freq == ts_covariate.freq,
          "The dataset contains some target/covariates series pair that have incompatible "
          'time axes (not the same "freq") and thus cannot be matched',
      )
  
      freq = ts_target.freq
  
      return idx + _index_diff(
          self=ts_target.end_time(),
          other=ts_covariate.end_time(),
          freq=freq,
      )
  
file_path: darts/darts/utils/data/utils.py
imports: from enum import Enum
  from typing import Union
  import pandas
  from darts import TimeSeries
  from darts.logging import raise_if_not
label_desc: Use image node_id 1 for calling a global function with example usage: _get_matching_index(ts_target, ts_covariate, idx) and returns: unknown