code: def test_diag_bad_input(k):
      # when input numpy array is neither 1d nor 2d:
      v = np.arange(2 * 3 * 4).reshape((2, 3, 4))
      with pytest.raises(
          ValueError, match="Array must be 1d or 2d only"
      ):
          da.diag(v, k)
  
      # when input dask array is neither 1d nor 2d:
      v = da.arange(2 * 3 * 4).reshape((2, 3, 4))
      with pytest.raises(
          ValueError, match="Array must be 1d or 2d only"
      ):
          da.diag(v, k)
  
      # when input is not an array:
      v = 1
      with pytest.raises(
          TypeError, match="v must be a dask array or numpy array"
      ):
          da.diag(v, k)
  
imports: from __future__ import annotations
  import pytest
  import numpy
  import pytest
  from tlz import concat
  import dask
  import dask.array
  from dask.array.core import normalize_chunks
  from dask.array.numpy_compat import AxisError
  from dask.array.utils import assert_eq, same_keys
label_desc: Use image node_id 16 for calling a global function with example usage: test_diag_bad_input(k) without return types