parameters: (obj, dtype=None, device=None, copy=None)
return_statement: return ret
docstring: Convert the input to an array.
  
      Parameters
      ----------
      obj : <array>, bool, int, float, NestedSequence[ bool | int | float ]
          Object to be converted to an array. Can be a Python scalar,
          a (possibly nested) sequence of Python scalars,
          or an object supporting DLPack or the Python buffer protocol.
      dtype : dtype, Optional
          output array data type. Default: None .
      device : Device, optional
          Device context on which the memory is allocated. Default is
          `mxnet.device.current_device()`.
      copy : bool, Optional
          Whether or not to make a copy of the input.
          If True, always copies.
          If False, never copies for input which supports DLPack or the buffer protocol,
          and raises ValueError in case that would be necessary.
          If None, reuses existing memory buffer if possible, copies otherwise. Default: None .
  
          An array containing the data from obj.
  
      Examples
      --------
      >>> np.asarray([1, 2, 3])
      array([1., 2., 3.])
  
      >>> np.asarray([[1, 2], [3, 4]], dtype=np.int32)
      array([[1, 2],
             [3, 4]], dtype=int32)
  
      >>> np.asarray([1.2], device=mx.gpu())
      array([1.2], device=gpu(0))
docstring_summary: Convert the input to an array.
docstring_tokens: Convert the input to an array .
function: def asarray(obj, dtype=None, device=None, copy=None):
      """
      Convert the input to an array.
  
      Parameters
      ----------
      obj : <array>, bool, int, float, NestedSequence[ bool | int | float ]
          Object to be converted to an array. Can be a Python scalar,
          a (possibly nested) sequence of Python scalars,
          or an object supporting DLPack or the Python buffer protocol.
      dtype : dtype, Optional
          output array data type. Default: None .
      device : Device, optional
          Device context on which the memory is allocated. Default is
          `mxnet.device.current_device()`.
      copy : bool, Optional
          Whether or not to make a copy of the input.
          If True, always copies.
          If False, never copies for input which supports DLPack or the buffer protocol,
          and raises ValueError in case that would be necessary.
          If None, reuses existing memory buffer if possible, copies otherwise. Default: None .
  
          An array containing the data from obj.
  
      Examples
      --------
      >>> np.asarray([1, 2, 3])
      array([1., 2., 3.])
  
      >>> np.asarray([[1, 2], [3, 4]], dtype=np.int32)
      array([[1, 2],
             [3, 4]], dtype=int32)
  
      >>> np.asarray([1.2], device=mx.gpu())
      array([1.2], device=gpu(0))
      """
      if isinstance(obj, numeric_types):
          dtype = dtype_from_number(obj) if dtype is None else dtype
          obj = _np.asarray(obj, dtype=dtype)
      elif isinstance(obj, _np.ndarray):
          if is_np_default_dtype():
              dtype = obj.dtype if dtype is None else dtype
          else:
              dtype = _np.float32 if dtype is None or obj.dtype is _np.float64 else dtype
      elif isinstance(obj, ndarray):
          if dtype is not None:
              obj = obj.astype(dtype, copy=copy)
          if device is not None:
              obj = obj.to_device(device)
          return obj
      elif hasattr(obj, '__dlpack__'):
          return from_dlpack(obj)
      else:
          if dtype is None:
              default_dtype = _np.float64 if is_np_default_dtype() else _np.float32
              dtype = obj.dtype if hasattr(obj, "dtype") else default_dtype
          try:
              obj = _np.array(obj, dtype=dtype)
          except Exception as e:
              # printing out the error raised by official NumPy's array function
              # for transparency on users' side
              raise TypeError('{}'.format(str(e)))
      if device is None:
          device = current_device()
      ret = empty(obj.shape, dtype=dtype, device=device)
      if len(obj.shape) == 0:
          ret[()] = obj
      else:
          ret[:] = obj
      return ret
function_tokens: def asarray ( obj , dtype = None , device = None , copy = None ) : if isinstance ( obj , numeric_types ) : dtype = dtype_from_number ( obj ) if dtype is None else dtype obj = _np . asarray ( obj , dtype = dtype ) elif isinstance ( obj , _np . ndarray ) : if is_np_default_dtype ( ) : dtype = obj . dtype if dtype is None else dtype else : dtype = _np . float32 if dtype is None or obj . dtype is _np . float64 else dtype elif isinstance ( obj , ndarray ) : if dtype is not None : obj = obj . astype ( dtype , copy = copy ) if device is not None : obj = obj . to_device ( device ) return obj elif hasattr ( obj , '__dlpack__' ) : return from_dlpack ( obj ) else : if dtype is None : default_dtype = _np . float64 if is_np_default_dtype ( ) else _np . float32 dtype = obj . dtype if hasattr ( obj , "dtype" ) else default_dtype try : obj = _np . array ( obj , dtype = dtype ) except Exception as e : # printing out the error raised by official NumPy's array function # for transparency on users' side raise TypeError ( '{}' . format ( str ( e ) ) ) if device is None : device = current_device ( ) ret = empty ( obj . shape , dtype = dtype , device = device ) if len ( obj . shape ) == 0 : ret [ ( ) ] = obj else : ret [ : ] = obj return ret