code: def _prefer_static_event_ndims(distribution):
      if distribution.event_shape.ndims is not None:
          return distribution.event_shape.ndims
      else:
          return tf.size(distribution.event_shape_tensor())
  
file_path: probability/tensorflow_probability/python/sts/forecast.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import mixture_same_family
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.experimental import util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.sts.internal import util
  from tensorflow.python.util import deprecation
label_desc: Use image node_id 1 for calling a global function with example usage: _prefer_static_event_ndims(distribution) and returns: distribution, tf