code: def patterson_f2(aca, acb):
      
  
      # check inputs
      aca = AlleleCountsArray(aca, copy=False)
      assert aca.shape[1] == 2, 'only biallelic variants supported'
      acb = AlleleCountsArray(acb, copy=False)
      assert acb.shape[1] == 2, 'only biallelic variants supported'
      check_dim0_aligned(aca, acb)
  
      # compute allele numbers
      sa = aca.sum(axis=1)
      sb = acb.sum(axis=1)
  
      # compute heterozygosities
      ha = h_hat(aca)
      hb = h_hat(acb)
  
      # compute sample frequencies for the alternate allele
      a = aca.to_frequencies()[:, 1]
      b = acb.to_frequencies()[:, 1]
  
      # compute estimator
      x = ((a - b) ** 2) - (ha / sa) - (hb / sb)
  
      return x
docs: Unbiased estimator for F2(A, B), the branch length between populations
      A and B.
  
      Parameters
      ----------
      aca : array_like, int, shape (n_variants, 2)
          Allele counts for population A.
      acb : array_like, int, shape (n_variants, 2)
          Allele counts for population B.
  
      Returns
      -------
      f2 : ndarray, float, shape (n_variants,)
  
      Notes
      -----
      See Patterson (2012), Appendix A.