code: def matricize(
      x: Union[ivy.Array, ivy.NativeArray],
      /,
      row_modes: Sequence[int],
      column_modes: Optional[Sequence[int]] = None,
      *,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Matricizes the given tensor.
  
      Parameters
      ----------
      x
          the input tensor
      row_modes
          modes to use as row of the matrix (in the desired order)
      column_modes
          modes to use as column of the matrix, in the desired order
          if None, the modes not in `row_modes` will be used in ascending order
      out
          optional output array, for writing the result to.
  
      ret
      -------
          ivy.Array : tensor of size (ivy.prod(x.shape[i] for i in row_modes), -1)
      """
      ndims = len(x.shape)
      row_indices = list(row_modes)
  
      if column_modes:
          column_indices = list(column_modes)
      else:
          column_indices = [
              i for i in range(ndims) if i not in row_indices
          ]
          if sorted(column_indices + row_indices) != list(range(ndims)):
              msg = (
                  "If you provide both column and row modes for the matricization then"
                  " column_modes + row_modes must contain all the modes of the tensor."
                  f" Yet, got row_modes={row_modes} and column_modes={column_modes}."
              )
              raise ValueError(msg)
  
      row_size, column_size = 1, 1
      row_size = int(ivy.prod([x.shape[i] for i in row_indices]))
      column_size = int(ivy.prod([x.shape[i] for i in column_indices]))
  
      return ivy.reshape(
          ivy.permute_dims(x, row_indices + column_indices),
          (row_size, column_size),
          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 54 for calling a global function with example usage: matricize(row_modes, column_modes) and returns: ivy