code: def tensor_shape_and_indices(
      draw,
      rank,
      min_dim=1,
      max_dim=4,
      dimensions=(2, 2, 2, 2, 3, 3, 4),
      letters="ijklmno",
  ):
      """Return a shape and a set of indices consistent with its dimensions."""
  
      # We don't draw dimensions directly but from an array of dimensions
      # so that we can ensure that all appearances of a particular letter
      # in a formula correspond to the same dimension.
      indices = draw(
          hps.tuples(*(rank * [hps.integers(min_dim, max_dim)]))
      )
      shape = tuple(dimensions[i] for i in indices)
      formula = "".join(letters[i] for i in indices)
      return formula, shape
  
imports: import hypothesis
  from hypothesis.extra import numpy
  import hypothesis.strategies
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.marginalize.logeinsumexp import _binary_einslogsumexp
  from tensorflow_probability.python.experimental.marginalize.logeinsumexp import logeinsumexp
  from tensorflow_probability.python.internal import test_util
  import tensorflow_probability.python.internal.hypothesis_testlib
label_desc: Use image node_id 3 for calling a global function with example usage: tensor_shape_and_indices(draw, rank, min_dim, max_dim, dimensions, letters) and returns: formula,  shape