code: def get_distortion_german(vold, vnew):
      """Distortion function for the german 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
      """
  
      # Distortion cost
      distort = {}
      distort["credit_history"] = pd.DataFrame(
          {
              "None/Paid": [0.0, 1.0, 2.0],
              "Delay": [1.0, 0.0, 1.0],
              "Other": [2.0, 1.0, 0.0],
          },
          index=["None/Paid", "Delay", "Other"],
      )
      distort["employment"] = pd.DataFrame(
          {
              "Unemployed": [0.0, 1.0, 2.0],
              "1-4 years": [1.0, 0.0, 1.0],
              "4+ years": [2.0, 1.0, 0.0],
          },
          index=["Unemployed", "1-4 years", "4+ years"],
      )
      distort["savings"] = pd.DataFrame(
          {
              "Unknown/None": [0.0, 1.0, 2.0],
              "<500": [1.0, 0.0, 1.0],
              "500+": [2.0, 1.0, 0.0],
          },
          index=["Unknown/None", "<500", "500+"],
      )
      distort["status"] = pd.DataFrame(
          {
              "None": [0.0, 1.0, 2.0],
              "<200": [1.0, 0.0, 1.0],
              "200+": [2.0, 1.0, 0.0],
          },
          index=["None", "<200", "200+"],
      )
      distort["credit"] = pd.DataFrame(
          {"Bad Credit": [0.0, 1.0], "Good Credit": [2.0, 0.0]},
          index=["Bad Credit", "Good Credit"],
      )
      distort["sex"] = pd.DataFrame(
          {0.0: [0.0, 2.0], 1.0: [2.0, 0.0]}, index=[0.0, 1.0]
      )
      distort["age"] = pd.DataFrame(
          {0.0: [0.0, 2.0], 1.0: [2.0, 0.0]}, index=[0.0, 1.0]
      )
  
      total_cost = 0.0
      for k in vold:
          if k in vnew:
              total_cost += distort[k].loc[vnew[k], vold[k]]
  
      return total_cost
  
imports: import numpy
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: get_distortion_german(vold, vnew) and returns: total_cost