code: def get_distortion_adult(vold, vnew):
      """Distortion function for the adult dataset. We set the distortion
      metric here. See section 4.3 in supplementary material of
      http://papers.nips.cc/paper/6988-optimized-pre-processing-for-discrimination-prevention
      for an example
  
      Note:
          Users can use this as templates to create other distortion functions.
  
      Args:
          vold (dict) : {attr:value} with old values
          vnew (dict) : dictionary of the form {attr:value} with new values
  
      Returns:
          d (value) : distortion value
      """
  
      # Define local functions to adjust education and age
      def adjustEdu(v):
          if v == ">12":
              return 13
          elif v == "<6":
              return 5
          else:
              return int(v)
  
      def adjustAge(a):
          if a == ">=70":
              return 70.0
          else:
              return float(a)
  
      def adjustInc(a):
          if a == "<=50K":
              return 0
          elif a == ">50K":
              return 1
          else:
              return int(a)
  
      # value that will be returned for events that should not occur
      bad_val = 3.0
  
      # Adjust education years
      eOld = adjustEdu(vold["Education Years"])
      eNew = adjustEdu(vnew["Education Years"])
  
      # Education cannot be lowered or increased in more than 1 year
      if (eNew < eOld) | (eNew > eOld + 1):
          return bad_val
  
      # adjust age
      aOld = adjustAge(vold["Age (decade)"])
      aNew = adjustAge(vnew["Age (decade)"])
  
      # Age cannot be increased or decreased in more than a decade
      if np.abs(aOld - aNew) > 10.0:
          return bad_val
  
      # Penalty of 2 if age is decreased or increased
      if np.abs(aOld - aNew) > 0:
          return 2.0
  
      # Adjust income
      incOld = adjustInc(vold["Income Binary"])
      incNew = adjustInc(vnew["Income Binary"])
  
      # final penalty according to income
      if incOld > incNew:
          return 1.0
      else:
          return 0.0
  
imports: import numpy
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: get_distortion_adult(vold, vnew) and returns: bad_val, bad_val, int, int, int, int, int, float, int, int, int, int, int