keras/src/layers/core/masking.py/Masking/call
class Masking:    def call(self, inputs):
        boolean_mask = ops.any(
            ops.not_equal(inputs, self.mask_value), axis=-1, keepdims=True
        )
        # Set masked outputs to 0
        outputs = inputs * backend.cast(boolean_mask, dtype=inputs.dtype)
        # Compute the mask and outputs simultaneously.
        try:
            outputs._keras_mask = ops.squeeze(boolean_mask, axis=-1)
        except AttributeError:
            # tensor is a C type.
            pass
        return outputs