code: def _canonicalize_event_ndims(target, event_ndims):
      """Returns `event_ndims` shaped parallel to `target`, repeating as needed."""
      # This is only here to support the possibility of different event_ndims across
      # different Tensors in the target structure.  Otherwise, event_ndims could
      # just be an integer (or None) and wouldn't need to be canonicalized to a
      # structure.
      if not nest.is_nested(event_ndims):
          return nest_util.broadcast_structure(target, event_ndims)
      else:
          return event_ndims
  
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import reducer
  from tensorflow_probability.python.experimental.stats import sample_stats
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.mcmc.internal import util
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling a global function with example usage: _canonicalize_event_ndims(target, event_ndims) and returns: nest_util, event_ndims