code: def _astype(tensor, dtype, order="K", casting="unsafe", copy=True):
      """
      Copy of the tensor, cast to a specified type.
  
      Parameters
      ----------
      dtype : str or dtype
          Typecode or data-type to which the array is cast.
      casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
          Controls what kind of data casting may occur. Defaults to 'unsafe'
          for backwards compatibility.
            * 'no' means the data types should not be cast at all.
            * 'equiv' means only byte-order changes are allowed.
            * 'safe' means only casts which can preserve values are allowed.
            * 'same_kind' means only safe casts or casts within a kind,
              like float64 to float32, are allowed.
            * 'unsafe' means any data conversions may be done.
      order : {'C', 'F', 'A', 'K'}, optional
          Controls the memory layout order of the result.
          'C' means C order, 'F' means Fortran order, 'A'
          means 'F' order if all the arrays are Fortran contiguous,
          'C' order otherwise, and 'K' means as close to the
          order the array elements appear in memory as possible.
          Default is 'K'.
      copy : bool, optional
          By default, astype always returns a newly allocated array. If this
          is set to false, and the `dtype`, `order`, and `subok`
          requirements are satisfied, the input array is returned instead
          of a copy.
  
      Returns
      -------
      arr_t : Tensor
          Unless `copy` is False and the other conditions for returning the input
          array are satisfied (see description for `copy` input parameter), `arr_t`
          is a new tensor of the same shape as the input array, with dtype, order
          given by `dtype`, `order`.
  
      Notes
      -----
      astype method returns an error if the string
      dtype to cast to is not long enough in 'safe' casting mode to hold the max
      value of integer/float array that is being casted. Previously the casting
      was allowed even if the result was truncated.
  
      Raises
      ------
      ComplexWarning
          When casting from complex to float or int. To avoid this,
          one should use ``a.real.astype(t)``.
  
      Examples
      --------
      >>> import mars.tensor as mt
      >>> x = mt.array([1, 2, 2.5])
      >>> x.execute()
      array([ 1. ,  2. ,  2.5])
  
      >>> x.astype(int).execute()
      array([1, 2, 2])
      """
      dtype = get_dtype(dtype)
      tensor_order = get_order(order, tensor.order)
  
      if tensor.dtype == dtype and tensor.order == tensor_order:
          return tensor if not copy else tensor.copy(order=order)
      elif not np.can_cast(tensor.dtype, dtype, casting=casting):
          raise TypeError(
              f"Cannot cast array from {tensor.dtype!r} to {dtype!r} "
              f"according to the rule {casting}"
          )
  
      op = TensorAstype(
          dtype=dtype,
          order=order,
          casting=casting,
          sparse=tensor.issparse(),
      )
      return op(tensor, order=tensor_order)
  
file_path: mars/mars/tensor/base/astype.py
imports: import numpy
  from ...None import opcodes
  from ...serialization.serializables import KeyField, StringField
  from ...utils import get_dtype
  from ..array_utils import as_same_device, device
  from ..operands import TensorHasInput, TensorOperandMixin
  from ..utils import get_order
label_desc: Use image node_id 1 for calling a global function with example usage: _astype(tensor, dtype, order, casting, copy) and returns: op, unknown