code: def XYZ_to_Lab(cobj, *args, **kwargs):
      
      illum = cobj.get_illuminant_xyz()
      temp_x = cobj.xyz_x / illum["X"]
      temp_y = cobj.xyz_y / illum["Y"]
      temp_z = cobj.xyz_z / illum["Z"]
  
      if temp_x > color_constants.CIE_E:
          temp_x = math.pow(temp_x, (1.0 / 3.0))
      else:
          temp_x = (7.787 * temp_x) + (16.0 / 116.0)
  
      if temp_y > color_constants.CIE_E:
          temp_y = math.pow(temp_y, (1.0 / 3.0))
      else:
          temp_y = (7.787 * temp_y) + (16.0 / 116.0)
  
      if temp_z > color_constants.CIE_E:
          temp_z = math.pow(temp_z, (1.0 / 3.0))
      else:
          temp_z = (7.787 * temp_z) + (16.0 / 116.0)
  
      lab_l = (116.0 * temp_y) - 16.0
      lab_a = 500.0 * (temp_x - temp_y)
      lab_b = 200.0 * (temp_y - temp_z)
      return LabColor(
          lab_l, lab_a, lab_b, observer=cobj.observer, illuminant=cobj.illuminant)
docs: Converts XYZ to Lab.