code: def categorical_lpdf(sample, p):
      if sample.size:
          return np.log(np.asarray(p)[sample])
      return np.asarray([])
  
imports: import logging
  import time
  import numpy
  from scipy.special import erf
  from .None import pyll
  from .pyll import scope
  from .pyll.stochastic import implicit_stochastic
  from .base import miscs_to_idxs_vals
  from .base import miscs_update_idxs_vals
  from .None import rand
label_desc: Use image node_id 2 for calling a global function with example usage: categorical_lpdf(sample, p) and returns: np, np