keras/src/layers/reshaping/flatten.py/Flatten/call
class Flatten:    def call(self, inputs):
        input_shape = inputs.shape
        rank = len(input_shape)

        if self._channels_first and rank > 1:
            # Switch to channels-last format.
            inputs = ops.transpose(inputs, axes=(0, *range(2, rank), 1))

        output_shape = tuple(
            dim if dim is not None else -1
            for dim in self.compute_output_shape(input_shape)
        )
        return ops.reshape(inputs, output_shape)