code: def flatten(a, order="C"):
      """
      Return a copy of the tensor collapsed into one dimension.
  
      Parameters
      ----------
      order : {'C', 'F', 'A', 'K'}, optional
          'C' means to flatten in row-major (C-style) order.
          'F' means to flatten in column-major (Fortran-
          style) order. 'A' means to flatten in column-major
          order if `a` is Fortran *contiguous* in memory,
          row-major order otherwise. 'K' means to flatten
          `a` in the order the elements occur in memory.
          The default is 'C'.
  
      Returns
      -------
      y : Tensor
          A copy of the input tensor, flattened to one dimension.
  
      See Also
      --------
      ravel : Return a flattened tensor.
      flat : A 1-D flat iterator over the tensor.
  
      Examples
      --------
  
      >>> import mars.tensor as mt
  
      >>> a = mt.array([[1,2], [3,4]])
      >>> a.flatten().execute()
      array([1, 2, 3, 4])
      """
  
      from ..reshape.reshape import TensorReshape, calc_shape
  
      if a.ndim == 1:
          return a
  
      new_shape = (
          np.nan
          if any(np.isnan(s) for s in a.shape)
          else calc_shape(a.size, -1)
      )
      tensor_order = get_order(order, a.order)
      op = TensorReshape(new_shape, dtype=a.dtype, create_view=False)
      return op(a, order=tensor_order, out_shape=new_shape)
  
label_desc: Use image node_id 1 for calling a global function with example usage: flatten(a, order) and returns: op, a