code: def conform_output(fn):
      """Decorator to handle impossible values
  
      Adds two optional kwargs, `coerce_fn` and `valid_fn`.
  
      `valid_fn` function stub
  
          def my_coerce_fn(some_literal) -> boolean
  
      `coerce_fn` function stub
  
          def my_coerce_fn(arr, x_i, y_i) -> some_literal
  
      Valid function is something run on each element of the, this is
      the function that we use to indicate whether the value is valid
      or not
  
      Coerce function has three arguments, the original matrix and
      the two indices of the invalid value x_i and y_i. This function
      will be run on all invalid values.
      """
  
      @wraps(fn)
      def wrapper(*args, **kwargs):
          def raise_error(arr, x_i, y_i):
              raise error.BadOutputError(
                  "{} does not conform".format(arr[x_i, y_i])
              )
  
          ## convert tuple to list so args can be modified
          args = list(args)
          # function that checks if the value is valid
          valid_fn = kwargs.get("valid_fn", u.constantly(True))
          # function that modifies the invalid value to something valid
          coerce_fn = kwargs.get("coerce_fn", raise_error)
  
          ## function invokation
          results = u.execute_fn_with_args_and_or_kwargs(
              fn, args, kwargs
          )
  
          # check each value to see if it's valid
          bool_arr = matrix.map_nd(u.complement(valid_fn), results)
          # get indices of invalid values
          invalid_indices = np.argwhere(bool_arr)
          # run the coerce fn on each invalid indice
          for x_i, y_i in invalid_indices:
              results[x_i, y_i] = coerce_fn(results, x_i, y_i)
  
          return results
  
      return wrapper
  
file_path: impyute/impyute/ops/wrapper.py
imports: from functools import wraps
  import numpy
  from .None import error
  from .None import matrix
  from .None import util
label_desc: Use image node_id 4 for calling a global function with example usage: conform_output(fn) and returns: wrapper, results