code: def _generate_shapes(
      n_dim: int = 5,
      n_terms: int = 4,
      iterations: int = 64,
      *,
      generator: torch.Generator,
  ) -> Iterable[Tuple[Tuple[int, ...], ...]]:
      """Generate shapes."""
      max_shape = torch.randint(
          low=2, high=32, size=(128,), generator=generator
      )
      for _ in range(iterations):
          # create broadcastable shapes
          idx = torch.randperm(max_shape.shape[0], generator=generator)[
              :n_dim
          ]
          this_max_shape = max_shape[idx]
          this_min_shape = torch.ones_like(this_max_shape)
          shapes = []
          for _j in range(n_terms):
              mask = this_min_shape
              while not (1 < mask.sum() < n_dim):
                  mask = torch.as_tensor(
                      torch.rand(size=(n_dim,), generator=generator)
                      < 0.3,
                      dtype=max_shape.dtype,
                  )
              this_array_shape = (
                  this_max_shape * mask + this_min_shape * (1 - mask)
              )
              shapes.append(tuple(this_array_shape.tolist()))
          yield tuple(shapes)
  
imports: import functools
  import itertools
  import operator
  import random
  import string
  import timeit
  import unittest
  from typing import Iterable, Tuple
  import numpy
  import pytest
  import torch
  from pykeen.utils import _weisfeiler_lehman_iteration, _weisfeiler_lehman_iteration_approx, calculate_broadcasted_elementwise_result_shape, clamp_norm, combine_complex, compact_mapping, compose, estimate_cost_of_sequence, flatten_dictionary, get_optimal_sequence, get_until_first_blank, iter_weisfeiler_lehman, logcumsumexp, project_entity, set_random_seed, split_complex, tensor_product, tensor_sum
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_shapes(n_dim, n_terms, iterations) without return types