code: def winsorize(
      a, limits=None, inclusive=(True, True), inplace=False, axis=None
  ):
      """Returns a Winsorized version of the input array.
  
      The (limits[0])th lowest values are set to the (limits[0])th percentile,
      and the (limits[1])th highest values are set to the (1 - limits[1])th
      percentile.
      Masked values are skipped.
  
  
      Parameters
      ----------
      a : sequence
          Input array.
      limits : {None, tuple of float}, optional
          Tuple of the percentages to cut on each side of the array, with respect
          to the number of unmasked data, as floats between 0. and 1.
          Noting n the number of unmasked data before trimming, the
          (n*limits[0])th smallest data and the (n*limits[1])th largest data are
          masked, and the total number of unmasked data after trimming
          is n*(1.-sum(limits)) The value of one limit can be set to None to
          indicate an open interval.
      inclusive : {(True, True) tuple}, optional
          Tuple indicating whether the number of data being masked on each side
          should be truncated (True) or rounded (False).
      inplace : {False, True}, optional
          Whether to winsorize in place (True) or to use a copy (False)
      axis : {None, int}, optional
          Axis along which to trim. If None, the whole array is trimmed, but its
          shape is maintained.
  
      Notes
      -----
      This function is applied to reduce the effect of possibly spurious outliers
      by limiting the extreme values.
  
      """
  
      def _winsorize1D(a, low_limit, up_limit, low_include, up_include):
          n = a.count()
          idx = a.argsort()
          if low_limit:
              if low_include:
                  lowidx = int(low_limit * n)
              else:
                  lowidx = np.round(low_limit * n).astype(int)
              a[idx[:lowidx]] = a[idx[lowidx]]
          if up_limit is not None:
              if up_include:
                  upidx = n - int(n * up_limit)
              else:
                  upidx = n - np.round(n * up_limit).astype(int)
              a[idx[upidx:]] = a[idx[upidx - 1]]
          return a
  
      # We are going to modify a: better make a copy
      a = ma.array(a, copy=np.logical_not(inplace))
  
      if limits is None:
          return a
      if (not isinstance(limits, tuple)) and isinstance(limits, float):
          limits = (limits, limits)
  
      # Check the limits
      (lolim, uplim) = limits
      errmsg = "The proportion to cut from the %s should be between 0. and 1."
      if lolim is not None:
          if lolim > 1.0 or lolim < 0:
              raise ValueError(
                  errmsg % "beginning" + "(got %s)" % lolim
              )
      if uplim is not None:
          if uplim > 1.0 or uplim < 0:
              raise ValueError(errmsg % "end" + "(got %s)" % uplim)
  
      (loinc, upinc) = inclusive
  
      if axis is None:
          shp = a.shape
          return _winsorize1D(
              a.ravel(), lolim, uplim, loinc, upinc
          ).reshape(shp)
      else:
          return ma.apply_along_axis(
              _winsorize1D, axis, a, lolim, uplim, loinc, upinc
          )
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from numpy import ndarray
  import numpy.ma
  from numpy.ma import masked, nomask
  from scipy._lib.six import iteritems
  import itertools
  import warnings
  from collections import namedtuple
  from .None import distributions
  import scipy.special
  from ._stats_mstats_common import _find_repeats, linregress, theilslopes, siegelslopes
label_desc: Use image node_id 41 for calling a global function with example usage: winsorize(a, limits, inclusive, inplace, axis) and returns: a, a, _winsorize1D, ma