code: def set_batch_diagonal(array, diag_val):
      batch_size, m, n = array.shape
      assert m == n
      rows, cols = np.diag_indices(n)
      array[:, rows, cols] = diag_val
  
imports: import numpy
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: set_batch_diagonal(array, diag_val) without return types