code: def count_alleles(self, max_allele=None, subpop=None):
          
  
          # check inputs
          subpop = _normalize_subpop_arg(subpop, self.shape[1])
  
          # determine alleles to count
          if max_allele is None:
              max_allele = self.max()
  
          # use optimisations
          values = memoryview_safe(self.values)
          mask = memoryview_safe(self.mask).view(dtype='u1') if self.mask is not None else None
          if subpop is None and mask is None:
              ac = genotype_array_count_alleles(values, max_allele)
          elif subpop is None:
              ac = genotype_array_count_alleles_masked(values, mask, max_allele)
          elif mask is None:
              ac = genotype_array_count_alleles_subpop(values, max_allele, subpop)
          else:
              ac = genotype_array_count_alleles_subpop_masked(values, mask, max_allele, subpop)
  
          return AlleleCountsArray(ac, copy=False)
docs: Count the number of calls of each allele per variant.
  
          Parameters
          ----------
          max_allele : int, optional
              The highest allele index to count. Alleles above this will be
              ignored.
          subpop : sequence of ints, optional
              Indices of samples to include in count.
  
          Returns
          -------
          ac : AlleleCountsArray
  
          Examples
          --------
  
          >>> import allel
          >>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
          ...                          [[0, 2], [1, 1]],
          ...                          [[2, 2], [-1, -1]]])
          >>> g.count_alleles()
          <AlleleCountsArray shape=(3, 3) dtype=int32>
          3 1 0
          1 2 1
          0 0 2
          >>> g.count_alleles(max_allele=1)
          <AlleleCountsArray shape=(3, 2) dtype=int32>
          3 1
          1 2
          0 0