pub fn poseidon2_hash(&mut self, array: &Array<C, Felt<C::F>>) -> Array<C, Felt<C::F>> {
        let mut state: Array<C, Felt<C::F>> = self.dyn_array(PERMUTATION_WIDTH);

        let break_flag: Var<_> = self.eval(C::N::zero());
        let last_index: Usize<_> = self.eval(array.len() - 1);
        self.range(0, array.len()).step_by(HASH_RATE).for_each(|i, builder| {
            builder.if_eq(break_flag, C::N::one()).then(|builder| {
                builder.break_loop();
            });
            // Insert elements of the chunk.
            builder.range(0, HASH_RATE).for_each(|j, builder| {
                let index: Var<_> = builder.eval(i + j);
                let element = builder.get(array, index);
                builder.set_value(&mut state, j, element);
                builder.if_eq(index, last_index).then(|builder| {
                    builder.assign(break_flag, C::N::one());
                    builder.break_loop();
                });
            });

            builder.poseidon2_permute_mut(&state);
        });

        state.truncate(self, Usize::Const(DIGEST_SIZE));
        state
    }
Applies the Poseidon2 permutation to the given array.

Reference: [p3_symmetric::PaddingFreeSponge]
crates/recursion/compiler/src/ir/poseidon.rs