code: def splrep(
      x,
      y,
      w=None,
      xb=None,
      xe=None,
      k=3,
      task=0,
      s=None,
      t=None,
      full_output=0,
      per=0,
      quiet=1,
  ):
      # see the docstring of `_fitpack_py/splrep`
      if task <= 0:
          _curfit_cache = {}
      x, y = map(atleast_1d, [x, y])
      m = len(x)
      if w is None:
          w = ones(m, float)
          if s is None:
              s = 0.0
      else:
          w = atleast_1d(w)
          if s is None:
              s = m - sqrt(2 * m)
      if not len(w) == m:
          raise TypeError(
              "len(w)=%d is not equal to m=%d" % (len(w), m)
          )
      if (m != len(y)) or (m != len(w)):
          raise TypeError(
              "Lengths of the first three arguments (x,y,w) must "
              "be equal"
          )
      if not (1 <= k <= 5):
          raise TypeError(
              "Given degree of the spline (k=%d) is not supported. "
              "(1<=k<=5)" % k
          )
      if m <= k:
          raise TypeError("m > k must hold")
      if xb is None:
          xb = x[0]
      if xe is None:
          xe = x[-1]
      if not (-1 <= task <= 1):
          raise TypeError("task must be -1, 0 or 1")
      if t is not None:
          task = -1
      if task == -1:
          if t is None:
              raise TypeError("Knots must be given for task=-1")
          numknots = len(t)
          _curfit_cache["t"] = empty((numknots + 2 * k + 2,), float)
          _curfit_cache["t"][k + 1 : -k - 1] = t
          nest = len(_curfit_cache["t"])
      elif task == 0:
          if per:
              nest = max(m + 2 * k, 2 * k + 3)
          else:
              nest = max(m + k + 1, 2 * k + 3)
          t = empty((nest,), float)
          _curfit_cache["t"] = t
      if task <= 0:
          if per:
              _curfit_cache["wrk"] = empty(
                  (m * (k + 1) + nest * (8 + 5 * k),), float
              )
          else:
              _curfit_cache["wrk"] = empty(
                  (m * (k + 1) + nest * (7 + 3 * k),), float
              )
          _curfit_cache["iwrk"] = empty((nest,), dfitpack_int)
      try:
          t = _curfit_cache["t"]
          wrk = _curfit_cache["wrk"]
          iwrk = _curfit_cache["iwrk"]
      except KeyError as e:
          raise TypeError(
              "must call with task=1 only after" " call with task=0,-1"
          ) from e
      if not per:
          n, c, fp, ier = dfitpack.curfit(
              task, x, y, w, t, wrk, iwrk, xb, xe, k, s
          )
      else:
          n, c, fp, ier = dfitpack.percur(
              task, x, y, w, t, wrk, iwrk, k, s
          )
      tck = (t[:n], c[:n], k)
      if ier <= 0 and not quiet:
          _mess = _iermess[ier][0] + "\tk=%d n=%d m=%d fp=%f s=%f" % (
              k,
              len(t),
              m,
              fp,
              s,
          )
          warnings.warn(RuntimeWarning(_mess), stacklevel=2)
      if ier > 0 and not full_output:
          if ier in [1, 2, 3]:
              warnings.warn(
                  RuntimeWarning(_iermess[ier][0]), stacklevel=2
              )
          else:
              try:
                  raise _iermess[ier][1](_iermess[ier][0])
              except KeyError as e:
                  raise _iermess["unknown"][1](
                      _iermess["unknown"][0]
                  ) from e
      if full_output:
          try:
              return tck, fp, ier, _iermess[ier][0]
          except KeyError:
              return tck, fp, ier, _iermess["unknown"][0]
      else:
          return tck
  
file_path: scipy/scipy/interpolate/_fitpack_impl.py
imports: import warnings
  import numpy
  from .None import _fitpack
  from numpy import atleast_1d, array, ones, zeros, sqrt, ravel, transpose, empty, iinfo, asarray
  from .None import dfitpack
label_desc: Use image node_id 3 for calling a global function with example usage: splrep(x, y, w, xb, xe, k, task, s, t, full_output, per, quiet) and returns: tck, tck,  fp,  ier,  _iermess, tck,  fp,  ier,  _iermess