class_docstr: Holds the inventory of 2D pieces and performs cutting.
  :param max_pieces_in_inventory: Size of the inventory. If full, the oldest pieces get discarded.
  :param raw_piece_size: Size of a fresh raw (= full-size) piece.
docstr: Attempt to perform the cutting. Remains of the cut piece are put back to inventory.
  
  :param maze_action: the cutting maze_action to perform
  :param ordered_piece: Dimensions of the piece that we should produce
  :return True if the cutting was successful, False on error.
docstr_tok: ["Attempt","to","perform","the","cutting",".","Remains","of","the","cut","piece","are","put","back","to","inventory",".",":","param","maze_action",":","the","cutting","maze_action","to","perform",":","param","ordered_piece",":","Dimensions","of","the","piece","that","we","should","produce",":","return","True","if","the","cutting","was","successful",",","False","on","error","."]
code: def cut(
      self, maze_action: Cutting2DMazeAction, ordered_piece: (int, int)
  ) -> bool:
      """Attempt to perform the cutting. Remains of the cut piece are put back to inventory.
  
      :param maze_action: the cutting maze_action to perform
      :param ordered_piece: Dimensions of the piece that we should produce
      :return True if the cutting was successful, False on error.
      """
      if maze_action.rotate:
          ordered_piece = ordered_piece[::-1]
  
      # Check the piece ID is valid
      if maze_action.piece_id >= len(self.pieces):
          return False
  
      # Check whether the cut is possible
      if any(
          [
              ordered_piece[dim] > available_size
              for dim, available_size in enumerate(
                  self.pieces[maze_action.piece_id]
              )
          ]
      ):
          return False
  
      # Perform the cut
      cutting_order = (
          [1, 0] if maze_action.reverse_cutting_order else [0, 1]
      )
      piece_to_cut = list(self.pieces.pop(maze_action.piece_id))
      for dim in cutting_order:
          residual = piece_to_cut.copy()
          residual[dim] = piece_to_cut[dim] - ordered_piece[dim]
          piece_to_cut[dim] = ordered_piece[dim]
          if residual[dim] > 0:
              self.store_piece(tuple(residual))
  
      return True
  
file_path: maze/tutorials/tutorial_maze_env/part01_core_env/env/inventory.py
imports: from .maze_action import Cutting2DMazeAction
label_desc: Use image node_id 5 for calling the Inventory obj's underlying member method code with example usage: obj.cut(maze_action, ordered_piece) and returns: True, False, False