code: def test_leading_transpose() -> None:
      dims = [1, 2, 3, 4]
      a = tf.zeros(dims)
      b = leading_transpose(a, [..., -1, -2])
      c = leading_transpose(a, [-1, ..., -2])
      d = leading_transpose(a, [-1, -2, ...])
      e = leading_transpose(a, [3, 2, ...])
      f = leading_transpose(a, [3, -2, ...])
  
      assert (
          len(a.shape) == len(b.shape) == len(c.shape) == len(d.shape)
      )
      assert len(a.shape) == len(e.shape) == len(f.shape)
      assert b.shape[-2:] == [4, 3]
      assert c.shape[0] == 4 and c.shape[-1] == 3
      assert d.shape[:2] == [4, 3]
      assert d.shape == e.shape == f.shape
  
file_path: GPflow/tests/gpflow/conditionals/test_util.py
imports: from typing import Optional, Tuple
  import numpy
  import pytest
  import tensorflow
  from _pytest.logging import LogCaptureFixture
  from numpy.testing import assert_allclose, assert_equal
  from gpflow import default_float
  from gpflow.conditionals.util import rollaxis_left, rollaxis_right, sample_mvn
  from gpflow.utilities.ops import leading_transpose
label_desc: Use image node_id 1 for calling a global function with example usage: test_leading_transpose() without return types