code: def __init__(self, arg1, shape=None, dtype=None, copy=False):
      _spbase.__init__(self)
      self._dict = {}
  
      self.dtype = getdtype(dtype, default=float)
      if isinstance(arg1, tuple) and isshape(arg1):  # (M,N)
          M, N = arg1
          self._shape = check_shape((M, N))
      elif issparse(arg1):  # Sparse ctor
          if arg1.format == self.format and copy:
              arg1 = arg1.copy()
          else:
              arg1 = arg1.todok()
  
          if dtype is not None:
              arg1 = arg1.astype(dtype, copy=False)
  
          self._dict.update(arg1)
          self._shape = check_shape(arg1.shape)
          self.dtype = arg1.dtype
      else:  # Dense ctor
          try:
              arg1 = np.asarray(arg1)
          except Exception as e:
              raise TypeError("Invalid input format.") from e
  
          if len(arg1.shape) != 2:
              raise TypeError(
                  "Expected rank <=2 dense array or matrix."
              )
  
          d = self._coo_container(arg1, dtype=dtype).todok()
          self._dict.update(d)
          self._shape = check_shape(arg1.shape)
          self.dtype = d.dtype
  
imports: import itertools
  import numpy
  from ._matrix import spmatrix
  from ._base import _spbase, sparray, issparse
  from ._index import IndexMixin
  from ._sputils import isdense, getdtype, isshape, isintlike, isscalarlike, upcast, upcast_scalar, check_shape
label_desc: Use image node_id 1 to create a new _dok_base object from inherited base classes: _spbase, IndexMixin with example: obj = _dok_base(arg1, shape, dtype, copy)