code: def init_ndarray(values, index, columns, dtype=None, copy=False):
      # input must be a ndarray, list, Series, index
  
      if isinstance(values, ABCSeries):
          if columns is None:
              if values.name is not None:
                  columns = [values.name]
          if index is None:
              index = values.index
          else:
              values = values.reindex(index)
  
          # zero len case (GH #2234)
          if not len(values) and columns is not None and len(columns):
              values = np.empty((0, 1), dtype=object)
  
      # we could have a categorical type passed or coerced to 'category'
      # recast this to an arrays_to_mgr
      if is_categorical_dtype(
          getattr(values, "dtype", None)
      ) or is_categorical_dtype(dtype):
          if not hasattr(values, "dtype"):
              values = prep_ndarray(values, copy=copy)
              values = values.ravel()
          elif copy:
              values = values.copy()
  
          index, columns = _get_axes(len(values), 1, index, columns)
          return arrays_to_mgr(
              [values], columns, index, columns, dtype=dtype
          )
      elif is_datetime64tz_dtype(values) or is_extension_array_dtype(
          values
      ):
          # GH#19157
          if columns is None:
              columns = [0]
          return arrays_to_mgr(
              [values], columns, index, columns, dtype=dtype
          )
  
      # by definition an array here
      # the dtypes will be coerced to a single dtype
      values = prep_ndarray(values, copy=copy)
  
      if dtype is not None:
          if not is_dtype_equal(values.dtype, dtype):
              try:
                  values = values.astype(dtype)
              except Exception as orig:
                  e = ValueError(
                      "failed to cast to '{dtype}' (Exception "
                      "was: {orig})".format(dtype=dtype, orig=orig)
                  )
                  raise_with_traceback(e)
  
      index, columns = _get_axes(
          *values.shape, index=index, columns=columns
      )
      values = values.T
  
      # if we don't have a dtype specified, then try to convert objects
      # on the entire block; this is to convert if we have datetimelike's
      # embedded in an object type
      if dtype is None and is_object_dtype(values):
          values = maybe_infer_to_datetimelike(values)
  
      return create_block_manager_from_blocks(
          [values], [columns, index]
      )
  
imports: from collections import OrderedDict
  import numpy
  import numpy.ma
  from pandas._libs import lib
  from pandas._libs.tslibs import IncompatibleFrequency
  import pandas.compat
  from pandas.compat import get_range_parameters, lmap, lrange, raise_with_traceback, range
  from pandas.core.dtypes.cast import construct_1d_arraylike_from_scalar, construct_1d_ndarray_preserving_na, construct_1d_object_array_from_listlike, infer_dtype_from_scalar, maybe_cast_to_datetime, maybe_cast_to_integer_array, maybe_castable, maybe_convert_platform, maybe_infer_to_datetimelike, maybe_upcast
  from pandas.core.dtypes.common import is_categorical_dtype, is_datetime64tz_dtype, is_dtype_equal, is_extension_array_dtype, is_extension_type, is_float_dtype, is_integer_dtype, is_iterator, is_list_like, is_object_dtype, pandas_dtype
  from pandas.core.dtypes.generic import ABCDataFrame, ABCDatetimeIndex, ABCIndexClass, ABCPandasArray, ABCPeriodIndex, ABCSeries, ABCTimedeltaIndex
  from pandas.core.dtypes.missing import isna
  from pandas.core import algorithms, common
  from pandas.core.arrays import Categorical, ExtensionArray, period_array
  from pandas.core.index import Index, _get_objs_combined_axis, _union_indexes, ensure_index
  from pandas.core.indexes import base
  from pandas.core.internals import create_block_manager_from_arrays, create_block_manager_from_blocks
  from pandas.core.internals.arrays import extract_array
label_desc: Use image node_id 3 for calling a global function with example usage: init_ndarray(values, index, columns, dtype, copy) and returns: create_block_manager_from_blocks, arrays_to_mgr, arrays_to_mgr