code: def cascade(T: np.ndarray, U: np.ndarray) -> np.ndarray:
      n = int(T.shape[1] / 2)
      J = np.linalg.inv(
          np.eye(n) - np.matmul(U[0:n, 0:n], T[n : 2 * n, n : 2 * n])
      )
      K = np.linalg.inv(
          np.eye(n) - np.matmul(T[n : 2 * n, n : 2 * n], U[0:n, 0:n])
      )
      S = np.block(
          [
              [
                  T[0:n, 0:n]
                  + np.matmul(
                      np.matmul(
                          np.matmul(T[0:n, n : 2 * n], J), U[0:n, 0:n]
                      ),
                      T[n : 2 * n, 0:n],
                  ),
                  np.matmul(
                      np.matmul(T[0:n, n : 2 * n], J), U[0:n, n : 2 * n]
                  ),
              ],
              [
                  np.matmul(
                      np.matmul(U[n : 2 * n, 0:n], K), T[n : 2 * n, 0:n]
                  ),
                  U[n : 2 * n, n : 2 * n]
                  + np.matmul(
                      np.matmul(
                          np.matmul(U[n : 2 * n, 0:n], K),
                          T[n : 2 * n, n : 2 * n],
                      ),
                      U[0:n, n : 2 * n],
                  ),
              ],
          ]
      )
      return S
  
file_path: nevergrad/nevergrad/functions/photonics/photonics.py
imports: import typing
  from pathlib import Path
  import numpy
  from scipy.linalg import toeplitz
label_desc: Use image node_id 3 for calling a global function with example usage: cascade(T, U) and returns: S