code: def map_alleles(self, mapping, max_allele=None):
          
  
          # ensure correct dimensionality and matching dtype
          mapping = asarray_ndim(mapping, 2, dtype=self.dtype)
          check_dim0_aligned(self, mapping)
          check_dim1_aligned(self, mapping)
  
          # use optimisation
          out = allele_counts_array_map_alleles(self.values, mapping, max_allele)
  
          # wrap and return
          return type(self)(out)
docs: Transform alleles via a mapping.
  
          Parameters
          ----------
          mapping : ndarray, int8, shape (n_variants, max_allele)
              An array defining the allele mapping for each variant.
          max_allele : int, optional
              Highest allele index expected in the output. If not provided
              will be determined from maximum value in `mapping`.
  
          Returns
          -------
          ac : AlleleCountsArray
  
          Examples
          --------
  
          >>> import allel
          >>> g = allel.GenotypeArray([[[0, 0], [0, 0]],
          ...                          [[0, 0], [0, 1]],
          ...                          [[0, 2], [1, 1]],
          ...                          [[2, 2], [-1, -1]]])
          >>> ac = g.count_alleles()
          >>> ac
          <AlleleCountsArray shape=(4, 3) dtype=int32>
          4 0 0
          3 1 0
          1 2 1
          0 0 2
          >>> mapping = [[1, 0, 2],
          ...            [1, 0, 2],
          ...            [2, 1, 0],
          ...            [1, 2, 0]]
          >>> ac.map_alleles(mapping)
          <AlleleCountsArray shape=(4, 3) dtype=int32>
          0 4 0
          1 3 0
          1 2 1
          2 0 0
  
          See Also
          --------
          create_allele_mapping