def infer_dtype_from_array(arr, pandas_dtype=False):
if isinstance(arr, np.ndarray):<EOL><INDENT>return arr.dtype, arr<EOL><DEDENT>if not is_list_like(arr):<EOL><INDENT>arr = [arr]<EOL><DEDENT>if pandas_dtype and is_extension_type(arr):<EOL><INDENT>return arr.dtype, arr<EOL><DEDENT>elif isinstance(arr, ABCSeries):<EOL><INDENT>return arr.dtype, np.asarray(arr)<EOL><DEDENT>inferred = lib.infer_dtype(arr, skipna=False)<EOL>if inferred in ['<STR_LIT:string>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>return (np.object_, arr)<EOL><DEDENT>arr = np.asarray(arr)<EOL>return arr.dtype, arr<EOL>
infer the dtype from a scalar or array

Parameters
----------
arr : scalar or array
pandas_dtype : bool, default False
    whether to infer dtype including pandas extension types.
    If False, array belongs to pandas extension types
    is inferred as object

Returns
-------
tuple (numpy-compat/pandas-compat dtype, array)

Notes
-----
if pandas_dtype=False. these infer to numpy dtypes
exactly with the exception that mixed / object dtypes
are not coerced by stringifying or conversion

if pandas_dtype=True. datetime64tz-aware/categorical
types will retain there character.

Examples
--------
>>> np.asarray([1, '1'])
array(['1', '1'], dtype='<U21')

>>> infer_dtype_from_array([1, '1'])
(numpy.object_, [1, '1'])