'Give names to all TrainOp, handle no names and duplicated names'

def validate_trainop_names(self):

    t_len = len(self.train_ops)
    for i in range(t_len):
        if (not self.train_ops[i].name):
            self.train_ops[i].name = 'Optimizer'
            self.train_ops[i].scope_name = 'Optimizer'
    for i in range(t_len):
        dupl = 0
        for j in range((i + 1), t_len):
            if (not self.train_ops[i].name):
                break
            if (self.train_ops[i].name == self.train_ops[j].name):
                if (dupl == 0):
                    self.train_ops[i].name += ('_' + str(dupl))
                    self.train_ops[i].scope_name = self.train_ops[i].name
                dupl += 1
                self.train_ops[j].name += ('_' + str(dupl))
                self.train_ops[j].scope_name = self.train_ops[j].name
