<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trim_empty_rows(self):
 """Remove all trailing empty rows."""

    if self.nrows != 0:
      row_index = 0
      for row_index, row in enumerate(reversed(self.rows)):
        if not self.is_row_empty(row):
          break
      self.nrows = len(self.rows) - row_index
      self.rows = self.rows[:self.nrows]
    return self