keras/src/ops/core.py/Scan/compute_output_spec
class Scan:    def compute_output_spec(self, f, init, xs, length):
        if xs is None:
            n = int(length)
            x = None
        else:
            n = (
                int(length)
                if length is not None
                else tree.flatten(xs)[0].shape[0]
            )
            x = xs[0]

        carry, y = backend.compute_output_spec(f, init, x)
        y = KerasTensor(shape=(n,) + y.shape, dtype=y.dtype, sparse=y.sparse)
        return carry, y