code: def unique(arr, tolerance=1e-6) -> np.ndarray:
      arr = sorted(arr.flatten())
      unique = []
      while len(arr) > 0:
          current = arr[0]
          lis = [xi for xi in arr if np.abs(current - xi) < tolerance]
          arr = [xi for xi in arr if not np.abs(lis[0] - xi) < tolerance]
          xi_lis_average = sum(lis) / len(lis)
          unique.append(xi_lis_average)
      return np.array(unique)