code: public SDVariable diagPart(String name, SDVariable x) {
          SDVariable ret = f().diagPart(x);
          return updateVariableNameAndReference(ret, name);
      }
docs: Extract the diagonal part from the input array.<br>
  If input is<br>
  [ 1, 0, 0]<br>
  [ 0, 2, 0]<br>
  [ 0, 0, 3]<br>
  then output is [1, 2, 3].<br>
  Supports higher dimensions: in general, out[i,...,k] = in[i,...,k,i,...,k]
  
  @param x Input variable
  @return Diagonal part of the input
  @see #diag(String, SDVariable)