def untile(self, tiles: Tensor) -> Tensor:
        """Reassemble the tiled tensor into image level representation.

        Args:
            tiles (Tensor): Tiles in shape: [num_h, num_w, batch, channel, tile_height, tile_width].

        Returns:
            Tensor: Image constructed from input tiles. Shape: [B, C, H, W].
        """
        # tiles have shape [num_h, num_w, batch, channel, tile_height, tile_width]
        _, _, batch, channels, tile_size_h, tile_size_w = tiles.shape

        # set tilers batch size as it might have been changed by previous tiling
        self.batch_size = batch

        # rearrange the tiles in order [tile_count * batch, channels, tile_height, tile_width]
        # the required shape for untiling
        tiles = tiles.permute(2, 0, 1, 3, 4, 5)
        tiles = tiles.contiguous().view(-1, channels, tile_size_h, tile_size_w)

        untiled = super().untile(tiles)

        return untiled  # noqa: RET504
Reassemble the tiled tensor into image level representation.

        Args:
            tiles (Tensor): Tiles in shape: [num_h, num_w, batch, channel, tile_height, tile_width].

        Returns:
            Tensor: Image constructed from input tiles. Shape: [B, C, H, W].
        
src/anomalib/pipelines/tiled_ensemble/components/utils/ensemble_tiling.py