class_docstr: Abstract class for all encoders
class_docstr_tok: ["Abstract","class","for","all","encoders"]
docstr: Avoid pitfalls: `encode_train()` or `encode_inference()` can be called multiple times or chained.
  Exclude any encoded components from `covariates` to generate and add the new encodings at a later time.
docstr_tok: ["Avoid","pitfalls",":","`","encode_train","(",")","`","or","`","encode_inference","(",")","`","can","be","called","multiple","times","or","chained",".","Exclude","any","encoded","components","from","`","covariates","`","to","generate","and","add","the","new","encodings","at","a","later","time","."]
code: def _drop_encoded_components(
      covariates: Optional[TimeSeries], components: pd.Index
  ) -> Optional[TimeSeries]:
      """Avoid pitfalls: `encode_train()` or `encode_inference()` can be called multiple times or chained.
      Exclude any encoded components from `covariates` to generate and add the new encodings at a later time.
      """
      if covariates is None:
          return covariates
  
      duplicate_components = components[
          components.isin(covariates.components)
      ]
      # case 1: covariates only consist of encoded components
      if len(duplicate_components) == len(covariates.components):
          covariates = None
      # case 2: covariates also have non-encoded components
      elif len(duplicate_components) and len(
          duplicate_components
      ) < len(covariates.components):
          covariates = covariates[
              list(
                  covariates.components[
                      ~covariates.components.isin(duplicate_components)
                  ]
              )
          ]
      return covariates
  
imports: from abc import ABC, abstractmethod
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import pandas
  from darts import TimeSeries
  from darts.dataprocessing.transformers import FittableDataTransformer
  from darts.logging import get_logger, raise_if, raise_log
  from darts.utils.timeseries_generation import generate_index
label_desc: Use image node_id 6 for calling the Encoder obj's underlying member method code with example usage: obj._drop_encoded_components(covariates, components) and returns: covariates, covariates