code: def precision(digits=None, index=None):
      """rounded outputs for the given function
  
      The function's output will be mapped to the given precision, where:
        - digits is an int that sets the rounding precision (can be negative)
        - if index tuple provided, only round at the given indices
  
      Examples:
        >>> @precision()
        ... def identity(x):
        ...     return x
        ...
        >>> identity([0.123, 1.789, 4.000])
        [0.0, 2.0, 4.0]
  
        >>> @precision(digits=1, index=(0,3,4))
        ... def squared(x):
        ...     return [i**2 for i in x]
        ...
        >>> squared([123.45, 123.45, 4.01, 4.01, 0.012, 0.012])
        [15239.9, 15239.9025, 16.080099999999998, 16.1, 0.0, 0.000144]
  
        >>> @precision(digits=-1, index=(0,3,4))
        ... def square(x):
        ...     return [i**2 for i in x]
        ...
        >>> square([123.45, 123.45, 4.01, 4.01, 0.012, 0.012])
        [15240.0, 15239.9025, 16.080099999999998, 20.0, 0.0, 0.000144]
      """
      digits = [digits or 0]
      if isinstance(index, int):
          index = (index,)
      index = [index]
  
      def _index(alist=None):
          index[0] = alist
  
      def _digits(aint=None):
          digits[0] = aint or 0
  
      def dec(f):
          def func(x, *args, **kwds):
              fx = f(x, *args, **kwds)
              if isinstance(fx, ndarray):
                  xtype = asarray
              else:
                  xtype = type(fx)
              y = round(fx, digits[0])
              if index[0] is None:
                  mask = ones(y.size, dtype=bool)
              else:
                  mask = zeros(y.size, dtype=bool)
                  try:
                      mask[sorted(index[0], key=abs)] = True
                  except IndexError:
                      pass
              y = choose(mask, (fx, y))  # .astype(float)
              return xtype(y)
  
          func.index = _index
          func.digits = _digits
          return func
  
      return dec
  
imports: from mystic.math.measures import *
  from mystic.math import almostEqual
  from numpy import sum
  from numpy import asfarray, asarray, choose, zeros, ones, ndarray
  from numpy import shape, broadcast, empty, atleast_1d
  from numpy import round, abs
  from random import randrange, shuffle
  from numpy import array, intersect1d, inf, isnan, where, choose, clip
  from numpy.random import uniform, choice
  from numpy import maximum, minimum
  from numpy import round, abs
  from mystic.tools import synchronized, connected
  from mystic.math.discrete import product_measure
label_desc: Use image node_id 19 for calling a global function with example usage: precision(digits, index) and returns: dec, func, xtype