code: def _get_diag_shape(v_shape, k):
      size_0, size_1 = 0, 0
      if k > 0:
          size_1 += k
      elif k < 0:
          size_0 -= k
      size = min(v_shape[0] - size_0, v_shape[1] - size_1)
      return (size,)
  
imports: import itertools
  import numpy
  from ...None import opcodes
  from ...serialization.serializables import KeyField, Int32Field
  from ...utils import has_unknown_shape
  from ..core import TENSOR_TYPE
  from ...lib.sparse import diag
  from ...lib.sparse.core import issparse, get_array_module, get_sparse_module
  from ...lib import sparse
  from ..core import TensorOrder
  from ..array_utils import create_array
  from .core import TensorHasInput
  from .zeros import TensorZeros
  from .array import tensor
label_desc: Use image node_id 1 for calling a global function with example usage: _get_diag_shape(v_shape, k) and returns: size