input: Write a python function to calculate the Gini index for a given 2D list.
  assert gini_index([[12,10,8], [8,7,6]]) == 0.05555555555555558
  assert gini_index([[1, 1, 1], [1, 1, 1]]) == 0.0
  assert gini_index([[5, 5], [5, 5]]) == 0.0
  assert gini_index([[1, 2], [3, 4]]) == 0.11111111111111116
output: def gini_index(groups):
      all_values = [value for group in groups for value in group]
      total_instances = len(all_values)
      if total_instances == 0:
          return 0.0
  
      mean_value = sum(all_values) / total_instances
      squared_diff_sum = sum((value - mean_value) ** 2 for value in all_values)
      gini = squared_diff_sum / (total_instances * mean_value ** 2)
      
      return gini