code: def matricize(tensor, row_modes, column_modes=None):
      """Matricizes the given tensor
  
      Parameters
      ----------
      tensor : tl.tensor
      row_modes : tuple[int]
          modes to use as row of the matrix (in the desired order)
      column_modes : tuple[int], default is None
          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
  
      Returns
      -------
      matrix : tl.tensor of size (prod(tensor.shape[i] for i in row_modes), -1)
      """
      try:
          row_indices = list(row_modes)
      except TypeError:
          row_indices = [row_modes]
  
      if column_modes is None:
          column_indices = [
              i for i in range(tl.ndim(tensor)) if i not in row_indices
          ]
      else:
          try:
              column_indices = list(column_modes)
          except TypeError:
              column_indices = [column_modes]
          if sorted(column_indices + row_indices) != list(
              range(tl.ndim(tensor))
          ):
              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 = prod(tl.shape(tensor)[i] for i in row_indices)
      column_size = prod(tl.shape(tensor)[i] for i in column_indices)
  
      return tl.reshape(
          tl.transpose(tensor, row_indices + column_indices),
          (row_size, column_size),
      )
  
file_path: tensorly/tensorly/base.py
imports: from math import prod
  from .None import backend
label_desc: Use image node_id 9 for calling a global function with example usage: matricize(tensor, row_modes, column_modes) and returns: tl