code: def ps_ir(
      *, draws, proposal_densities, target_densities, num_resampled, key
  ):
      logits = target_densities - proposal_densities
      logits = jnp.nan_to_num(logits, nan=-jnp.inf, neginf=-jnp.inf)
      idxs = jax.random.categorical(
          key=key, logits=logits, shape=(num_resampled,)
      )
      return draws[idxs]
  
file_path: probability/discussion/pathfinder/pathfinder.py
imports: from typing import Tuple, List, Sequence, Callable
  import jax
  import jax.numpy
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: ps_ir() and returns: draws