code: def parse_percentiles(
      percentiles: Sequence[float] | float | None,
      *,
      inject_median: bool = False,
  ) -> Sequence[float]:
      """
      Transforms raw percentiles into our preferred format, adding the 50th percentile.
  
      Raises a ValueError if the percentile sequence is invalid
      (e.g. outside the range [0, 1])
      """
      if isinstance(percentiles, float):
          percentiles = [percentiles]
      elif percentiles is None:
          percentiles = []
      if not all((0 <= p <= 1) for p in percentiles):
          raise ValueError(
              "`percentiles` must all be in the range [0, 1]"
          )
  
      sub_50_percentiles = sorted(p for p in percentiles if p < 0.5)
      at_or_above_50_percentiles = sorted(
          p for p in percentiles if p >= 0.5
      )
  
      if inject_median and (
          not at_or_above_50_percentiles
          or at_or_above_50_percentiles[0] != 0.5
      ):
          at_or_above_50_percentiles = [
              0.5,
              *at_or_above_50_percentiles,
          ]
  
      return [*sub_50_percentiles, *at_or_above_50_percentiles]
  
imports: from __future__ import annotations
  import inspect
  import os
  import re
  import sys
  import warnings
  from collections.abc import MappingView, Sized
  from enum import Enum
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Generator, Iterable, Literal, Sequence, TypeVar
  import polars
  from polars import functions
  from polars.datatypes import FLOAT_DTYPES, INTEGER_DTYPES, Boolean, Date, Datetime, Decimal, Duration, Int64, String, Time
  from polars.dependencies import _check_for_numpy
  from polars.dependencies import numpy
label_desc: Use image node_id 25 for calling a global function with example usage: parse_percentiles(percentiles) and returns: list