code: def _event_size(tensor_structure, event_ndims):
      """Returns the number of elements in the event-portion of a structure."""
      event_shapes = nest.map_structure(
          lambda t, nd: ps.slice(ps.shape(t), [ps.rank(t) - nd], [nd]),
          tensor_structure,
          event_ndims,
      )
      return sum(
          ps.reduce_prod(shape) for shape in nest.flatten(event_shapes)
      )
  
imports: import collections
  import functools
  import sys
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.bijectors import ldj_ratio
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 3 for calling a global function with example usage: _event_size(tensor_structure, event_ndims) and returns: sum