def test_routine(encoder, merge_covs: bool, comps_expected: pd.Index):
                """checks general behavior for `encode_train` and `encode_inference` with and without merging the
                output with original covariates"""
                n = 1
                covs_train = encoder.encode_train(
                    target=ts, covariates=covs, merge_covariates=merge_covs
                )
                assert covs_train.end_time() == ts.end_time()

                # check the encoded component names
                assert encoder.components.equals(comps_expected)
                if not merge_covs:
                    assert covs_train.components.equals(comps_expected)
                else:
                    assert comps_expected.isin(covs_train.components).all()
                    # check that original components are in output when merging
                    assert covs_train[list(covs.components)] == covs

                # check the same for inference
                covs_inf = encoder.encode_inference(
                    n=n, target=ts, covariates=covs, merge_covariates=merge_covs
                )
                # if we give input `covs` the encoder will use the same index as `covs`
                assert covs_inf.end_time() == covs.end_time()
                assert encoder.components.equals(comps_expected)
                if not merge_covs:
                    assert covs_inf.components.equals(comps_expected)
                else:
                    assert comps_expected.isin(covs_inf.components).all()
                    assert covs_inf[list(covs.components)] == covs

                # check that train_inference gives equal results
                covs_train_inf = encoder.encode_train_inference(
                    n=n, target=ts, covariates=covs, merge_covariates=merge_covs
                )
                assert covs_train_inf.start_time() == covs_train.start_time()
                assert covs_train_inf.end_time() == covs_inf.end_time()
                assert covs_train_inf[covs_train.time_index] == covs_train
                assert covs_train_inf[covs_inf.time_index] == covs_inf

                # we can use the output of `encode_train()` as input for `encode_train()` and get the same
                # results (encoded components get overwritten)
                covs_train2 = encoder.encode_train(
                    target=ts, covariates=covs_train, merge_covariates=merge_covs
                )
                if merge_covs:
                    assert covs_train2 == covs_train
                else:
                    overlap = covs_train.slice_intersect(covs_train2)
                    assert covs_train2 == overlap

                # we can use the output of `encode_train()` as input for `encode_inference()`. The encoded components
                # are dropped internally and appended again at the end
                covs_inf2 = encoder.encode_inference(
                    n=n, target=ts, covariates=covs_train, merge_covariates=merge_covs
                )
                # We get the same results with `merge_covariates=True` (as original covariates will still be in input)
                if merge_covs:
                    assert covs_inf2 == covs_inf
                # We get only the minimum required time spans with `merge_covariates=False` as input covariates will
                # are not in output of `encode_train()/inference()`
                else:
                    overlap = covs_inf.slice_intersect(covs_inf2)
                    if isinstance(
                        encoder.index_generator, PastCovariatesIndexGenerator
                    ):
                        assert len(covs_inf2) == input_chunk_length
                        assert covs_inf2.end_time() == ts.end_time()
                        assert covs_inf2 == overlap
                    else:
                        assert (
                            len(covs_inf2) == input_chunk_length + output_chunk_length
                        )
                        assert (
                            covs_inf2.end_time()
                            == ts.end_time() + ts.freq * output_chunk_length
                        )
                        overlap_inf = covs_inf2.slice_intersect(overlap)
                        assert overlap_inf == overlap

                # we can use the output of `encode_inference()` as input for `encode_inference()` and get the
                # same results (encoded components get overwritten)
                covs_inf3 = encoder.encode_inference(
                    n=1, target=ts, covariates=covs_inf2, merge_covariates=merge_covs
                )
                assert covs_inf3 == covs_inf2
checks general behavior for `encode_train` and `encode_inference` with and without merging the
                output with original covariates
darts/tests/dataprocessing/encoders/test_encoders.py