<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def transform(self, X, batch_size=100, show_progressbar=False):
 """ Transform input to a distance matrix by measuring the L2 distance. Parameters X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to use in transformation. This may affect the transformation in stateful, i.e. sequential SOMs. show_progressbar : bool Whether to show a progressbar during transformation. Returns ------- transformed : numpy array A matrix containing the distance from each datapoint to all neurons. The distance is normally expressed as euclidean distance, but can be any arbitrary metric. """

        X = self._check_input(X)

        batched = self._create_batches(X, batch_size, shuffle_data=False)

        activations = []
        prev = self._init_prev(batched)

        for x in tqdm(batched, disable=not show_progressbar):
            prev = self.forward(x, prev_activation=prev)[0]
            activations.extend(prev)

        activations = np.asarray(activations, dtype=np.float64)
        activations = activations[:X.shape[0]]
        return activations.reshape(X.shape[0], self.num_neurons)