code: def reflection_conv(
      kernel: jnp.ndarray, array: jnp.ndarray, reverse: bool = True
  ) -> jnp.ndarray:
      r"""Convolves an array with a kernel, using reflection padding.
      The kernel is supposed to have the same number of dimensions as the array.
  
      Args:
        kernel (jnp.ndarray): The kernel to convolve with.
        array (jnp.ndarray): The array to convolve.
        reverse (bool, optional): Whether to reverse the kernel before convolving.
          Defaults to True.
  
      Returns:
        The convolved array.
      """
      # Reflection padding the array appropriately
      pad = [((x - 1) // 2, (x - 1) // 2) for x in kernel.shape]
      f = jnp.pad(array, pad, mode="wrap")
  
      if reverse:
          # Reverse the kernel over all axes
          kernel = jnp.flip(kernel, axis=tuple(range(kernel.ndim)))
  
      # Apply kernel
      return jsp.signal.convolve(f, kernel, mode="valid")
  
imports: from typing import List, Tuple, Union, no_type_check
  import numpy
  from jax import numpy
  from jax import scipy
label_desc: Use image node_id 1 for calling a global function with example usage: reflection_conv(kernel, array, reverse) and returns: jsp