def _tukey_hh_l_skewness_and_kurtosis(h_params):
  """Computes L-skewness and L-kurtosis for a Tukey HH distribution.

  Args:
    h_params: An np.array with dimension 2 on the first axis. The slice
    h_params[0, ...] contains the left parameter of the distribution and
    h_params[1, ...] the right parameter.

  Returns:
    The tuple (L_skewness, L_kurtosis) for the given parameters. Each entry
    has the same shape as h_params, except for the first axis, which is
    removed.
  """
  def skewness_num(h1, h2):
    return (12 * np.sqrt(2.0 - h1) * (h2 - 2.0) * (h2 - 1.0) *
            np.arctan(1.0 / np.sqrt(2.0 - h1)))

  def skewness_den(h):
    return h * np.sqrt(2 - h) - np.sqrt(2 - h)

  def kurtosis_den_part(h):
    return h * np.sqrt(2.0 - h) - np.sqrt(2.0 - h)

  hl = h_params[0, ...]
  hr = h_params[1, ...]
  dtype = h_params.dtype
  skewness = (skewness_num(hl, hr) -
              np.pi * (hl - hr) * (hl - 2.0) * (hr - 2.0) -
              skewness_num(hr, hl)) / (
                  2 * np.pi * np.sqrt((hl - 2.0) * (hr - 2.0)) *
                  (skewness_den(hl) + skewness_den(hr)))
  kurtosis_num_1 = (
      hr * np.sqrt((hl - 4.0) * (hl - 2.0) * (hl - 1.0) * (hr - 2.0)) -
      2.0 * np.sqrt((hl - 4.0) * (hl - 1.0)))
  kurtosis_num_2 = (hl * (hl - 3.0) * np.sqrt((hl - 4.0) * (hl - 1.0)) +
                    np.sqrt((hl - 4.0) * (hl - 2.0) * (hl - 1.0) * (hr - 2.0)))
  kurtosis_num_3 = (30.0 * (hl - 1.0) *
                    np.sqrt((hl - 4.0) * (hl - 2.0) * (hr - 2.0) / (hl - 1.0)) *
                    (hr - 1.0) * np.arctan(np.sqrt(1.0 + 2.0 / (hl - 4.0))))
  kurtosis_num_4 = (30.0 * (hl - 2) *
                    np.sqrt((hl - 4.0) * (hl - 1.0)) * (hl - 1.0) *
                    np.arctan(np.sqrt(1.0 + 2.0 / (hr - 4.0))))
  kurtosis_den = (np.pi * np.sqrt((4.0 - hl) * (2.0 - hl) * (1.0 - hl)) *
                  (kurtosis_den_part(hl) + kurtosis_den_part(hr)))
  kurtosis = (6.0 * np.pi * (kurtosis_num_1 - kurtosis_num_2) +
              kurtosis_num_3 + kurtosis_num_4) / kurtosis_den
  return (skewness.astype(dtype), kurtosis.astype(dtype))
Computes L-skewness and L-kurtosis for a Tukey HH distribution.

  Args:
    h_params: An np.array with dimension 2 on the first axis. The slice
    h_params[0, ...] contains the left parameter of the distribution and
    h_params[1, ...] the right parameter.

  Returns:
    The tuple (L_skewness, L_kurtosis) for the given parameters. Each entry
    has the same shape as h_params, except for the first axis, which is
    removed.
  
tensorflow_transform/gaussianization.py