What does group.setdefault() do in this context?
I looked at the documentation [https://docs.python.org/2/library/stdtypes.html#dict.setdefault]


  setdefault(key[, default]):
  
  If key is in the dictionary, return its value.
  
  If not, insert key with a value of default and return default. default defaults to None


However, seeing as the output of group.setdefault() isn't being saved in a variable. I find this odd.
To be more specific, this code is included in the definition of a class of a scheduler. I am using pytorch and as I'm new, I'm having difficulties understanding the code. So any python/pytorch ninja that can figure this out? 

Here's a simplified version of the class:

     class BaseLRScheduler(_LRScheduler):
         def __init__(self, optimizer, last_epoch=-1):

             self.optimizer = optimizer
             if last_epoch == -1:
                for group in optimizer.param_groups:
                    group.setdefault('initial_lr', group['lr'])


             self.base_lrs = list(
                  map(lambda group: group['initial_lr'], optimizer.param_groups))
             self.step(last_epoch + 1)
             self.last_epoch = last_epoch


This is the problematic part of code for me:

     if last_epoch == -1:
         for group in optimizer.param_groups:
              group.setdefault('initial_lr', group['lr'])


The fact that a function returns a value does not make it mandatory to use that value.

In this case,
if 'initial_lr' is in the dictionary, nothing happens, but, 
If 'initial_lr' is not in the dictionary, insert it with the value of group['lr'].

For example:

d = {'a': 1}
d.setdefault('a', 2)
print(d)
d.setdefault('b', 3)
print(d)


Outputs

{'a': 1}
{'a': 1, 'b': 3}

