code: def to_events(
      labels: pd.Series,
      freq_as_period: bool = True,
      merge_consecutive: Optional[bool] = None,
  ) -> List[Union[Tuple[pd.Timestamp, pd.Timestamp], pd.Timestamp]]:
      ...
  
file_path: adtk/src/adtk/data/_data.py
imports: from typing import Dict, List, Optional, Tuple, Union, overload
  import numpy
  import pandas
label_desc: Use image node_id 3 for calling a global function with example usage: to_events(labels, freq_as_period, merge_consecutive) without return types