code: def flatten(
      x: Union[ivy.Array, ivy.NativeArray],
      /,
      *,
      copy: Optional[bool] = None,
      start_dim: Optional[int] = 0,
      end_dim: Optional[int] = -1,
      order: Optional[str] = "C",
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Flattens input by reshaping it into a one-dimensional tensor. If
      start_dim or end_dim are passed, only dimensions starting with start_dim
      and ending with end_dim are flattened. The order of elements in input is
      unchanged.
  
      Parameters
      ----------
      x
          input array to flatten.
      copy
          boolean indicating whether or not to copy the input array.
          If True, the function must always copy.
          If False, the function must never copy.
          In case copy is False we avoid copying by returning a view of the input array.
      start_dim
          first dim to flatten. If not set, defaults to 0.
      end_dim
          last dim to flatten. If not set, defaults to -1.
      order
          Read the elements of the input container using this index order,
          and place the elements into the reshaped array using this index order.
          ‘C’ means to read / write the elements using C-like index order,
          with the last axis index changing fastest, back to the first axis index
          changing slowest.
          ‘F’ means to read / write the elements using Fortran-like index order, with
          the first index changing fastest, and the last index changing slowest.
          Note that the ‘C’ and ‘F’ options take no account of the memory layout
          of the underlying array, and only refer to the order of indexing.
          Default order is 'C'
      out
          optional output array, for writing the result to.
  
      Returns
      -------
      ret
          the flattened array over the specified dimensions.
  
      Examples
      --------
      With :class:`ivy.Array` input:
  
      >>> x = ivy.array([[1,2], [3,4]])
      >>> ivy.flatten(x)
      ivy.array([1, 2, 3, 4])
  
      >>> x = ivy.array([[1,2], [3,4]])
      >>> ivy.flatten(x, order='F')
      ivy.array([1, 3, 2, 4])
  
      >>> x = ivy.array(
          [[[[ 5,  5,  0,  6],
           [17, 15, 11, 16],
           [ 6,  3, 13, 12]],
  
          [[ 6, 18, 10,  4],
           [ 5,  1, 17,  3],
           [14, 14, 18,  6]]],
  
  
         [[[12,  0,  1, 13],
           [ 8,  7,  0,  3],
           [19, 12,  6, 17]],
  
          [[ 4, 15,  6, 15],
           [ 0,  5, 17,  9],
           [ 9,  3,  6, 19]]],
  
  
         [[[17, 13, 11, 16],
           [ 4, 18, 17,  4],
           [10, 10,  9,  1]],
  
          [[19, 17, 13, 10],
           [ 4, 19, 16, 17],
           [ 2, 12,  8, 14]]]]
           )
      >>> ivy.flatten(x, start_dim = 1, end_dim = 2)
      ivy.array(
          [[[ 5,  5,  0,  6],
            [17, 15, 11, 16],
            [ 6,  3, 13, 12],
            [ 6, 18, 10,  4],
            [ 5,  1, 17,  3],
            [14, 14, 18,  6]],
  
           [[12,  0,  1, 13],
            [ 8,  7,  0,  3],
            [19, 12,  6, 17],
            [ 4, 15,  6, 15],
            [ 0,  5, 17,  9],
            [ 9,  3,  6, 19]],
  
           [[17, 13, 11, 16],
            [ 4, 18, 17,  4],
            [10, 10,  9,  1],
            [19, 17, 13, 10],
            [ 4, 19, 16, 17],
            [ 2, 12,  8, 14]]]))
      """
      if x.shape == ():
          x = ivy.reshape(x, (1, -1))[0, :]
      if start_dim == end_dim:
          return ivy.inplace_update(out, x) if ivy.exists(out) else x
      if start_dim not in range(-len(x.shape), len(x.shape)):
          raise IndexError(
              "Dimension out of range (expected to be in range of"
              f" {[-len(x.shape), len(x.shape) - 1]}, but got {start_dim}"
          )
      if end_dim not in range(-len(x.shape), len(x.shape)):
          raise IndexError(
              "Dimension out of range (expected to be in range of"
              f" {[-len(x.shape), len(x.shape) - 1]}, but got {end_dim}"
          )
      if start_dim < 0:
          start_dim = len(x.shape) + start_dim
      if end_dim < 0:
          end_dim = len(x.shape) + end_dim
      c = 1
      for i in range(start_dim, end_dim + 1):
          c *= x.shape[i]
      lst = [c]
      if start_dim != 0:
          for i in range(0, start_dim):
              lst.insert(i, x.shape[i])
      for i in range(end_dim + 1, len(x.shape)):
          lst.insert(i, x.shape[i])
      return ivy.reshape(x, tuple(lst), order=order, out=out)
  
imports: from typing import Optional, Union, Tuple, Iterable, Sequence, Callable, Any, Literal, List
  from numbers import Number
  from functools import partial
  import math
  import ivy
  from ivy.func_wrapper import handle_out_argument, handle_partial_mixed_function, to_native_arrays_and_back, inputs_to_native_shapes, handle_nestable, handle_array_like_without_promotion, handle_view, inputs_to_ivy_arrays, handle_array_function, handle_device, handle_backend_invalid
  from ivy.functional.ivy.general import _numel
  from ivy.utils.backend import current_backend
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 4 for calling a global function with example usage: flatten() and returns: ivy, unknown