code: def label_piecewise_normal(
      means: npt.ArrayLike,
      lengths: npt.ArrayLike,
      std_dev: Union[npt.ArrayLike, float] = 1.0,
      repeated_labels: bool = True,
  ) -> npt.ArrayLike:
      """Generate labels for a series composed of segments.
  
      Parameters
      ----------
      means : array_like
          Means of the segments to be generated
      lengths : array_like
          Lengths of the segments to be generated
      std_dev : float or array_like
          Standard deviations of the segments to be generated
      repeated_labels : bool
          Flag to indicate whether segment labels should be repeated for similar segments.
          If ``True`` same label will be assigned for segments with same mean and std_dev,
          independently of length. If ``False`` each consecutive segment will have
          a unique label.
  
      Returns
      -------
      labels : np.array
          integer encoded array of labels, same length as data
      """
      if isinstance(std_dev, (float, int)):
          std_dev = np.repeat(std_dev, len(means))
      if repeated_labels:
          unique_labels = labels_with_repeats(means, std_dev)
      else:
          unique_labels = range(len(lengths))
      return np.repeat(unique_labels, lengths)
  
file_path: sktime/sktime/annotation/datagen.py
imports: from typing import Union
  import numpy
  import numpy.typing
  from sklearn.utils.validation import check_random_state
label_desc: Use image node_id 6 for calling a global function with example usage: label_piecewise_normal(means, lengths, std_dev, repeated_labels) and returns: np