


encoded_tensor = encode(bucket.buffer())  # encode gradients
     >>>     fut = torch.distributed.all_reduce(encoded_tensor).get_future()
     >>>     # Define the then callback to decode.
     >>>     def decode(fut):
     >>>         decoded_tensor = decode(fut.value()[0])  # decode gradients
     >>>         return decoded_tensor
     >>>     return fut.then(decode)
     >>> ddp.register_comm_hook(state=None, hook=encode_and_decode)



