code: def _block_diag_torch(tensors):
      """Torch implementation of scipy.linalg.block_diag"""
      torch = _i("torch")
      sizes = np.array([t.shape for t in tensors])
      shape = np.sum(sizes, axis=0).tolist()
      res = torch.zeros(
          shape, dtype=tensors[0].dtype, device=tensors[0].device
      )
  
      # get the diagonal indices at which new block
      # diagonals need to be inserted
      p = np.cumsum(sizes, axis=0)
  
      # converted the diagonal indices to row and column indices
      ridx, cidx = np.stack([p - sizes, p]).T
  
      for t, r, c in zip(tensors, ridx, cidx):
          row = np.arange(*r).reshape(-1, 1)
          col = np.arange(*c).reshape(1, -1)
          res[row, col] = t
  
      return res
  
imports: from importlib import import_module
  import autoray
  import numpy
  import semantic_version
  from scipy.linalg import block_diag
  from .utils import get_deep_interface
label_desc: Use image node_id 30 for calling a global function with example usage: _block_diag_torch(tensors) and returns: res