code: def random_parafac2(
      shapes: Sequence[int],
      rank: int,
      /,
      *,
      dtype: Optional[Union[ivy.Dtype, ivy.NativeDtype]] = None,
      full: Optional[bool] = False,
      seed: Optional[int] = None,
      normalise_factors: Optional[bool] = True,
  ) -> Union[ivy.Parafac2Tensor, ivy.Array]:
      """Generate a random PARAFAC2 tensor.
  
      Parameters
      ----------
      shapes
          A shapes of the tensor to generate
      rank
          rank of the Parafac2 decomposition
      full
          if True, a full tensor is returned otherwise,
          the decomposed tensor is returned
       seed
          seed for generating random numbers
  
      Returns
      -------
        ivy.Parafac2Tensor
      """
      if any(shape[1] != shapes[0][1] for shape in shapes):
          raise ValueError(
              "All matrices must have equal number of columns."
          )
  
      projection_matrices = [
          ivy.qr(
              ivy.random_uniform(
                  shape=(shape[0], rank), dtype=dtype, seed=seed
              )
          )[0]
          for shape in shapes
      ]
      weights, factors = ivy.random_cp(
          [len(shapes), rank, shapes[0][1]],
          rank,
          normalise_factors=False,
          seed=seed,
          dtype=dtype,
      )
  
      parafac2_tensor = ivy.Parafac2Tensor(
          (weights, factors, projection_matrices)
      )
  
      if normalise_factors:
          parafac2_tensor = ivy.Parafac2Tensor.parafac2_normalise(
              parafac2_tensor
          )
  
      if full:
          return ivy.Parafac2Tensor.parafac2_to_tensor(parafac2_tensor)
      else:
          return parafac2_tensor
  
imports: from typing import Union, Tuple, Optional, Sequence, Iterable, Generator
  import warnings
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.utils.exceptions import handle_exceptions
  from ivy.func_wrapper import outputs_to_ivy_arrays, handle_nestable, to_native_arrays_and_back, handle_out_argument, infer_dtype, handle_array_like_without_promotion, inputs_to_ivy_arrays, handle_device, handle_backend_invalid, handle_array_function
label_desc: Use image node_id 19 for calling a global function with example usage: random_parafac2() and returns: ivy, parafac2_tensor