code: def asarray_tuplesafe(values, dtype=None):
      if not (
          isinstance(values, (list, tuple))
          or hasattr(values, "__array__")
      ):
          values = list(values)
      elif isinstance(values, ABCIndexClass):
          return values.values
  
      if isinstance(values, list) and dtype in [np.object_, object]:
          return construct_1d_object_array_from_listlike(values)
  
      result = np.asarray(values, dtype=dtype)
  
      if issubclass(result.dtype.type, compat.string_types):
          result = np.asarray(values, dtype=object)
  
      if result.ndim == 2:
          # Avoid building an array of arrays:
          # TODO: verify whether any path hits this except #18819 (invalid)
          values = [tuple(x) for x in values]
          result = construct_1d_object_array_from_listlike(values)
  
      return result
  
imports: import collections
  from datetime import datetime, timedelta
  from functools import partial
  import inspect
  import numpy
  from pandas._libs import lib, tslibs
  import pandas.compat
  from pandas.compat import PY36, OrderedDict, iteritems
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  from pandas.core.dtypes.common import is_array_like, is_bool_dtype, is_extension_array_dtype, is_integer
  from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries
  from pandas.core.dtypes.inference import _iterable_not_string
  from pandas.core.dtypes.missing import isna, isnull, notnull
label_desc: Use image node_id 15 for calling a global function with example usage: asarray_tuplesafe(values, dtype) and returns: result, construct_1d_object_array_from_listlike, values