code: def _support(dist):
      """Compute support of a discrete distribution.
  
      Currently supports `Bernoulli`, `Categorical` and `Sample`.
  
      Args:
        dist: a `tfd.Distribution` instance.
  
      Returns:
        pair consisting of support of distribution and the rank of
        the underlying event type.
      """
  
      if isinstance(dist, bernoulli_lib.Bernoulli):
          return tf.range(2), 0
      elif isinstance(dist, categorical_lib.Categorical):
          return tf.range(tf.shape(dist.probs_parameter())[-1]), 0
      elif isinstance(dist, sample_lib.Sample):
          # The support of `tfd.Sample` is the n-fold cartesian product
          # of the supports of the underlying distributions where
          # `n` is the total size of the sample shape.
  
          (
              sample_shape,
              n,
          ) = dist._expand_sample_shape_to_vector(  # pylint: disable=protected-access
              dist.sample_shape, "expand_sample_shape"
          )
          p, rank = _support(dist.distribution)
          product = _power(p, n)
          new_shape = ps.concat(
              [ps.shape(product)[:-1], sample_shape], axis=-1
          )
  
          new_rank = rank + tf.compat.dimension_value(
              sample_shape.shape[0]
          )
          return tf.reshape(product, new_shape), new_rank
      else:
          raise ValueError(
              "Unable to find support for distribution " + str(dist)
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import joint_distribution
  from tensorflow_probability.python.distributions import joint_distribution_coroutine
  from tensorflow_probability.python.distributions import sample
  from tensorflow_probability.python.experimental.marginalize.logeinsumexp import logeinsumexp
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
label_desc: Use image node_id 4 for calling a global function with example usage: _support(dist) and returns: tf,  int, tf,  int, tf,  new_rank