<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, row={}, step=None):
 """Adds or updates a history step. If row isn't specified, will write the current state of row. If step is specified, the row will be written only when add() is called with a different step value. run.history.row["duration"] = 1.0 run.history.add({"loss": 1}) => {"duration": 1.0, "loss": 1} """

        if not isinstance(row, collections.Mapping):
            raise wandb.Error('history.add expects dict-like object')

        if step is None:
            self.update(row)
            if not self.batched:
                self._write()
        else:
            if not isinstance(step, numbers.Integral):
                raise wandb.Error(
                    "Step must be an integer, not {}".format(step))
            elif step < self._steps:
                warnings.warn(
                    "Adding to old History rows isn't currently supported. Dropping.", wandb.WandbWarning)
                return
            elif step == self._steps:
                pass
            elif self.batched:
                raise wandb.Error(
                    "Can't log to a particular History step ({}) while in batched mode.".format(step))
            else:  # step > self._steps
                self._write()
                self._steps = step

            self.update(row)