code: def nary_einsum(draw, max_num_tensors):
      """Return an entire `einsum` example."""
  
      n = draw(hps.integers(min_value=1, max_value=max_num_tensors))
      lhss = []
      tensors = []
      for _ in range(n):
          rank = draw(hps.integers(min_value=0, max_value=4))
          # Deliberately choosing values in a restricted range so as not to cause
          # underflow making results comparable with ordinary `einsum`.
          lhs_t, t = draw(
              indexed_tensor(rank, min_value=1e-5, max_value=1.0)
          )
          lhss.append(lhs_t)
          tensors.append(t)
  
      # Find all indices in use anywhere on left hand side of formula.
      # We build a right hand side by selecting a list of these
      # letters using each letter at most once.
      letters = list(set("".join(lhss)))
      if letters:
          rhs_letters = draw(
              hps.lists(
                  hps.sampled_from(letters),
                  max_size=len(letters),
                  unique=True,
              )
          )
      else:
          rhs_letters = []
      rhs = "".join(rhs_letters)
  
      # Combine pieces on left hand side with right hand side to make
      # a single formula.
      # Some example formulas this strategy can produce:
      #
      #  'kjjm,mllm,j,kmk->jmlk'
      #  'l,lllk,kkll,->'
      #  'mm,jk,l,kll->'
      #  ',km,,jkjl->m'
      #  'jmm,k,m,km->km'
      #  'k,l,kjl,ml->jkl'
  
      formula = "{}->{}".format(",".join(lhss), rhs)
  
      return formula, tensors
  
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 5 for calling a global function with example usage: nary_einsum(draw, max_num_tensors) and returns: formula,  tensors