input: 
  from typing import List
  import numpy as np
  
  def gini(x: List[float]) -> float:
      """Calculate Gini Coefficient of a given dataset.
      >>> gini([2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21])
      0.605
      """
      # calculate the frequency of each item in x
      x_value_counts = np.array(np.unique(x, return_counts=True)[1])
  
      # calculate the cumulative sum of x_value_counts
      x_cum_sum = np.cumsum(x_value_counts)
  
      # calculate the Lorenz values
      n = len(x)
      lorenz = x_cum_sum / n
      lorenz = np.insert(lorenz, 0, 0) # add 0 to the beginning of array
  
      # calculate the Gini Coefficient
      width = lorenz[:-1] - lorenz[1:]
      gini_coef = (1 / n) * np.sum(width * (lorenz[1:] + lorenz[:-1]))
  
      return gini_coef
  
output:     return round(gini_coef, 3)