code: def merge_selected_cells(self, selection):
          
  
          tab = self.grid.current_table
  
          # Get the selection bounding box
          bbox = selection.get_bbox()
          if bbox is None:
              row, col, tab = self.grid.actions.cursor
              (bb_top, bb_left), (bb_bottom, bb_right) = (row, col), (row, col)
          else:
              (bb_top, bb_left), (bb_bottom, bb_right) = bbox
          merge_area = bb_top, bb_left, bb_bottom, bb_right
  
          # Check if top-left cell is already merged
          cell_attributes = self.grid.code_array.cell_attributes
          tl_merge_area = cell_attributes[(bb_top, bb_left, tab)]["merge_area"]
  
          if tl_merge_area is not None and tl_merge_area[:2] == merge_area[:2]:
              self.unmerge(tl_merge_area, tab)
          else:
              self.merge(merge_area, tab)
docs: Merges or unmerges cells that are in the selection bounding box
  
          Parameters
          ----------
          selection: Selection object
          \tSelection for which attr toggle shall be returned