code: def _default_covariance_event_ndims(event_ndims, shape):
      """Try to default `event_ndims` to 'full covariance' for the given `shape`."""
      shape_rank = tf.get_static_value(ps.rank_from_shape(shape))
      if event_ndims is None:
          if shape_rank is None:
              raise ValueError(
                  "Cannot default to computing all covariances for "
                  "samples of statically unknown rank."
              )
          else:
              event_ndims = shape_rank
      if shape_rank is not None and event_ndims > shape_rank:
          raise ValueError(
              "Cannot calculate cross-products in {} dimensions for "
              "samples of rank {}".format(event_ndims, shape_rank)
          )
      if event_ndims > 13:
          # This 13 is because we use an einsum to construct the needed outer product
          # in `_batch_outer_product`.  Each event dimension requires two distinct
          # characters to represent, and we don't want to rely on `tf.einsum`
          # supporting a larger alphabet than lower-case English letters.
          raise ValueError("`event_ndims` over 13 not supported")
      return event_ndims
  
imports: import functools
  import math
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.mcmc import diagnostic
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 for calling a global function with example usage: _default_covariance_event_ndims(event_ndims, shape) and returns: event_ndims