code: def quantile(series: Sequence, quantile: Union[None, float] = None):
      """
      If `quantile` is `None`, return the quantile _rank_ of the last
      value of `series` wrt former series values.
  
      If `quantile` is a value between 0 and 1, return the _value_ of
      `series` at this quantile. If used to working with percentiles, just
      divide your percentile amount with 100 to obtain quantiles.
  
          >>> quantile(self.data.Close[-20:], .1)
          162.130
          >>> quantile(self.data.Close)
          0.13
      """
      if quantile is None:
          try:
              last, series = series[-1], series[:-1]
              return np.mean(series < last)
          except IndexError:
              return np.nan
      assert 0 <= quantile <= 1, "quantile must be within [0, 1]"
      return np.nanpercentile(series, quantile * 100)
  
imports: from collections import OrderedDict
  from inspect import currentframe
  from itertools import compress
  from numbers import Number
  from typing import Callable, Optional, Sequence, Union
  import numpy
  import pandas
  from ._plotting import plot_heatmaps
  from ._stats import compute_stats
  from ._util import _Array, _as_str
  from .backtesting import Strategy
label_desc: Use image node_id 5 for calling a global function with example usage: quantile(series, quantile) and returns: np, np, np