class_docstr: N-dimensional array.
  
  Examples
  ========
  
  Create an N-dim array of zeros:
  
  >>> from sympy import MutableDenseNDimArray
  >>> a = MutableDenseNDimArray.zeros(2, 3, 4)
  >>> a
  [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]]
  
  Create an N-dim array from a list;
  
  >>> a = MutableDenseNDimArray([[2, 3], [4, 5]])
  >>> a
  [[2, 3], [4, 5]]
  
  >>> b = MutableDenseNDimArray([[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]])
  >>> b
  [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]
  
  Create an N-dim array from a flat list with dimension shape:
  
  >>> a = MutableDenseNDimArray([1, 2, 3, 4, 5, 6], (2, 3))
  >>> a
  [[1, 2, 3], [4, 5, 6]]
  
  Create an N-dim array from a matrix:
  
  >>> from sympy import Matrix
  >>> a = Matrix([[1,2],[3,4]])
  >>> a
  Matrix([
  [1, 2],
  [3, 4]])
  >>> b = MutableDenseNDimArray(a)
  >>> b
  [[1, 2], [3, 4]]
  
  Arithmetic operations on N-dim arrays
  
  >>> a = MutableDenseNDimArray([1, 1, 1, 1], (2, 2))
  >>> b = MutableDenseNDimArray([4, 4, 4, 4], (2, 2))
  >>> c = a + b
  >>> c
  [[5, 5], [5, 5]]
  >>> a - b
  [[-3, -3], [-3, -3]]
class_docstr_tok: ["N-dimensional","array",".","Examples","========","Create","an","N-dim","array","of","zeros",":",">",">",">","from","sympy","import","MutableDenseNDimArray",">",">",">","a","=","MutableDenseNDimArray.zeros","(","2",",","3",",","4",")",">",">",">","a","[","[","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]","]",",","[","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]","]","]","Create","an","N-dim","array","from","a","list",";",">",">",">","a","=","MutableDenseNDimArray","(","[","[","2",",","3","]",",","[","4",",","5","]","]",")",">",">",">","a","[","[","2",",","3","]",",","[","4",",","5","]","]",">",">",">","b","=","MutableDenseNDimArray","(","[","[","[","1",",","2","]",",","[","3",",","4","]",",","[","5",",","6","]","]",",","[","[","7",",","8","]",",","[","9",",","10","]",",","[","11",",","12","]","]","]",")",">",">",">","b","[","[","[","1",",","2","]",",","[","3",",","4","]",",","[","5",",","6","]","]",",","[","[","7",",","8","]",",","[","9",",","10","]",",","[","11",",","12","]","]","]","Create","an","N-dim","array","from","a","flat","list","with","dimension","shape",":",">",">",">","a","=","MutableDenseNDimArray","(","[","1",",","2",",","3",",","4",",","5",",","6","]",",","(","2",",","3",")",")",">",">",">","a","[","[","1",",","2",",","3","]",",","[","4",",","5",",","6","]","]","Create","an","N-dim","array","from","a","matrix",":",">",">",">","from","sympy","import","Matrix",">",">",">","a","=","Matrix","(","[","[","1,2","]",",","[","3,4","]","]",")",">",">",">","a","Matrix","(","[","[","1",",","2","]",",","[","3",",","4","]","]",")",">",">",">","b","=","MutableDenseNDimArray","(","a",")",">",">",">","b","[","[","1",",","2","]",",","[","3",",","4","]","]","Arithmetic","operations","on","N-dim","arrays",">",">",">","a","=","MutableDenseNDimArray","(","[","1",",","1",",","1",",","1","]",",","(","2",",","2",")",")",">",">",">","b","=","MutableDenseNDimArray","(","[","4",",","4",",","4",",","4","]",",","(","2",",","2",")",")",">",">",">","c","=","a","+","b",">",">",">","c","[","[","5",",","5","]",",","[","5",",","5","]","]",">",">",">","a","-","b","[","[","-3",",","-3","]",",","[","-3",",","-3","]","]"]
code: def _handle_ndarray_creation_inputs(
      cls, iterable=None, shape=None, **kwargs
  ):
      from sympy.matrices.matrixbase import MatrixBase
      from sympy.tensor.array import SparseNDimArray
  
      if shape is None:
          if iterable is None:
              shape = ()
              iterable = ()
          # Construction of a sparse array from a sparse array
          elif isinstance(iterable, SparseNDimArray):
              return iterable._shape, iterable._sparse_array
  
          # Construct N-dim array from another N-dim array:
          elif isinstance(iterable, NDimArray):
              shape = iterable.shape
  
          # Construct N-dim array from an iterable (numpy arrays included):
          elif isinstance(iterable, Iterable):
              iterable, shape = cls._scan_iterable_shape(iterable)
  
          # Construct N-dim array from a Matrix:
          elif isinstance(iterable, MatrixBase):
              shape = iterable.shape
  
          else:
              shape = ()
              iterable = (iterable,)
  
      if isinstance(iterable, (Dict, dict)) and shape is not None:
          new_dict = iterable.copy()
          for k, v in new_dict.items():
              if isinstance(k, (tuple, Tuple)):
                  new_key = 0
                  for i, idx in enumerate(k):
                      new_key = new_key * shape[i] + idx
                  iterable[new_key] = iterable[k]
                  del iterable[k]
  
      if isinstance(shape, (SYMPY_INTS, Integer)):
          shape = (shape,)
  
      if not all(
          isinstance(dim, (SYMPY_INTS, Integer)) for dim in shape
      ):
          raise TypeError("Shape should contain integers only.")
  
      return tuple(shape), iterable
  
imports: from sympy.core.basic import Basic
  from sympy.core.containers import Dict, Tuple
  from sympy.core.expr import Expr
  from sympy.core.kind import Kind, NumberKind, UndefinedKind
  from sympy.core.numbers import Integer
  from sympy.core.singleton import S
  from sympy.core.sympify import sympify
  from sympy.external.gmpy import SYMPY_INTS
  from sympy.printing.defaults import Printable
  import itertools
  from collections.abc import Iterable
label_desc: Use image node_id 8 for calling the NDimArray obj's underlying member method code with example usage: obj._handle_ndarray_creation_inputs(cls, iterable, shape) and returns: tuple,  iterable, iterable,  iterable