code: def partial_unfold(
      tensor, mode=0, skip_begin=1, skip_end=0, ravel_tensors=False
  ):
      """Partially unfolds a tensor while ignoring the specified number of dimensions at the beginning and the end.
  
          For instance, if the first dimension of the tensor is the number of samples, to unfold each sample,
          set skip_begin=1.
          This would, for each i in ``range(tensor.shape[0])``, unfold ``tensor[i, ...]``.
  
      Parameters
      ----------
      tensor : ndarray
          tensor of shape n_samples x n_1 x n_2 x ... x n_i
      mode : int
          indexing starts at 0, therefore mode is in range(0, tensor.ndim)
      skip_begin : int, optional
          number of dimensions to leave untouched at the beginning
      skip_end : int, optional
          number of dimensions to leave untouched at the end
      ravel_tensors : bool, optional
          if True, the unfolded tensors are also flattened
  
      Returns
      -------
      ndarray
          partially unfolded tensor
      """
      if ravel_tensors:
          new_shape = [-1]
      else:
          new_shape = [tensor.shape[mode + skip_begin], -1]
  
      if skip_begin:
          new_shape = [
              tensor.shape[i] for i in range(skip_begin)
          ] + new_shape
  
      if skip_end:
          new_shape += [
              tensor.shape[-i] for i in range(1, 1 + skip_end)
          ]
  
      return tl.reshape(
          tl.moveaxis(tensor, mode + skip_begin, skip_begin), new_shape
      )
  
file_path: tensorly/tensorly/base.py
imports: from math import prod
  from .None import backend
label_desc: Use image node_id 5 for calling a global function with example usage: partial_unfold(tensor, mode, skip_begin, skip_end, ravel_tensors) and returns: tl