<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dict(self, data=True):
 """Dictionary representation of variable."""

        item = {'dims': self.dims,
                'attrs': decode_numpy_dict_values(self.attrs)}
        if data:
            item['data'] = ensure_us_time_resolution(self.values).tolist()
        else:
            item.update({'dtype': str(self.dtype), 'shape': self.shape})
        return item