code: def maybe_assert_categorical_param_correctness(
      is_init, validate_args, probs, logits
  ):
      """Return assertions for `Categorical`-type distributions."""
      assertions = []
  
      # In init, we can always build shape and dtype checks because
      # we assume shape doesn't change for Variable backed args.
      if is_init:
          x, name = (
              (probs, "probs") if logits is None else (logits, "logits")
          )
  
          if not dtype_util.is_floating(x.dtype):
              raise TypeError(
                  "Argument `{}` must having floating type.".format(
                      name
                  )
              )
  
          msg = "Argument `{}` must have rank at least 1.".format(name)
          ndims = tensorshape_util.rank(x.shape)
          if ndims is not None:
              if ndims < 1:
                  raise ValueError(msg)
          elif validate_args:
              x = tf.convert_to_tensor(x)
              probs = (
                  x if logits is None else None
              )  # Retain tensor conversion.
              logits = x if probs is None else None
              assertions.append(
                  assert_util.assert_rank_at_least(x, 1, message=msg)
              )
  
      if not validate_args:
          assert not assertions  # Should never happen.
          return []
  
      if logits is not None:
          if is_init != tensor_util.is_ref(logits):
              logits = tf.convert_to_tensor(logits)
              assertions.extend(
                  distribution_util.assert_categorical_event_shape(
                      logits
                  )
              )
  
      if probs is not None:
          if is_init != tensor_util.is_ref(probs):
              probs = tf.convert_to_tensor(probs)
              assertions.extend(
                  [
                      assert_util.assert_non_negative(probs),
                      assert_util.assert_near(
                          tf.reduce_sum(probs, axis=-1),
                          np.array(
                              1,
                              dtype=dtype_util.as_numpy_dtype(
                                  probs.dtype
                              ),
                          ),
                          message="Argument `probs` must sum to 1.",
                      ),
                  ]
              )
              assertions.extend(
                  distribution_util.assert_categorical_event_shape(
                      probs
                  )
              )
  
      return assertions
  
imports: import numpy
  import six
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softmax_centered
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 2 for calling a global function with example usage: maybe_assert_categorical_param_correctness(is_init, validate_args, probs, logits) and returns: assertions, list