//  [python]
def set_allele_representations(self, allele_representations, force_surgery=False):
        """
        Set the allele representations in use by this model. This means mutating
        the weights for the allele input embedding layer.

        Rationale: instead of passing in the allele sequence for each data point
        during model training or prediction (which is expensive in terms of
        memory usage), we pass in an allele index between 0 and n-1 where n is
        the number of alleles in some universe of possible alleles. This index
        is used in the model to lookup the corresponding allele sequence. This
        function sets the lookup table.

        See also: AlleleEncoding.allele_representations()

        Parameters
        ----------
        allele_representations : numpy.ndarray of shape (a, l, m)
            where a is the total number of alleles,
                  l is the allele sequence length,
                  m is the length of the vectors used to represent amino acids
        """
        configure_tensorflow()
        from tensorflow.keras.models import clone_model

        reshaped = allele_representations.reshape(
            (
                allele_representations.shape[0],
                numpy.prod(allele_representations.shape[1:]),
            )
        )
        original_model = self.network()
        layer = original_model.get_layer("allele_representation")
        existing_weights_shape = (layer.input_dim, layer.output_dim)

        # Only changes to the number of supported alleles (not the length of
        # the allele sequences) are allowed.
        assert existing_weights_shape[1:] == reshaped.shape[1:], (
            existing_weights_shape,
            reshaped.shape,
        )

        if existing_weights_shape[0] > reshaped.shape[0] and not force_surgery:
            # Extend with NaNs so we can avoid having to reshape the weights
            # matrix, which is expensive.
            reshaped = numpy.append(
                reshaped,
                numpy.ones(
                    [existing_weights_shape[0] - reshaped.shape[0], reshaped.shape[1]]
                )
                * numpy.nan,
                axis=0,
            )

        if existing_weights_shape != reshaped.shape:
            # Network surgery required. Make a new network with this layer's
            # dimensions changed. Kind of a hack.
            layer.input_dim = reshaped.shape[0]
            new_model = clone_model(original_model)

            # copy weights for other layers over
            for layer in new_model.layers:
                if layer.name != "allele_representation":
                    layer.set_weights(
                        original_model.get_layer(name=layer.name).get_weights()
                    )

            self._network = new_model
            self.update_network_description()

            layer = new_model.get_layer("allele_representation")

            # Disable the old model to catch bugs.
            def throw(*args, **kwargs):
                raise RuntimeError("Using a disabled model!")

            original_model.predict = (
                original_model.to_json
            ) = (
                original_model.get_weights
            ) = original_model.fit = original_model.fit_generator = throw

        layer.set_weights([reshaped])