<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_command_line(self):
 """Writes command line to attributes. The command line is written to the file's ``attrs['cmd']``. If this attribute already exists in the file (this can happen when resuming from a checkpoint), ``attrs['cmd']`` will be a list storing the current command line and all previous command lines. """

        cmd = [" ".join(sys.argv)]
        try:
            previous = self.attrs["cmd"]
            if isinstance(previous, str):
                # convert to list
                previous = [previous]
            elif isinstance(previous, numpy.ndarray):
                previous = previous.tolist()
        except KeyError:
            previous = []
        self.attrs["cmd"] = cmd + previous