code: def set_collapsed(block, val):
          
          if block is None:
              return
          state = block.userState()
          if state == -1:
              state = 0
          state &= 0x77FFFFFF
          state |= int(val) << 27
          block.setUserState(state)
docs: Sets the fold trigger state (collapsed or expanded).
  
          :param block: The block to modify
          :param val: The new trigger state (True=collapsed, False=expanded)