<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_reg(self, addr, value, mask=0xFFFFFFFF, delay_us=0):
 """ Write to memory address in target Note: mask option is not supported by stub loaders, use update_reg() function. """

        return self.check_command("write target memory", self.ESP_WRITE_REG,
                                  struct.pack('<IIII', addr, value, mask, delay_us))