code: def dynamic_topology_update(batch_idx):
      if args.dist_optimizer == "win_put":
          num_out_neighbors = len(bf.out_neighbor_ranks())
          sent_neighbor = bf.out_neighbor_ranks()[
              batch_idx % num_out_neighbors
          ]
          optimizer.dst_weights = {sent_neighbor: 1.0}
      elif args.dist_optimizer == "neighbor_allreduce":
          send_neighbors, recv_neighbors = next(
              dynamic_neighbor_allreduce_gen
          )
          optimizer.dst_weights = send_neighbors
          optimizer.src_weights = {
              r: 1 / (len(recv_neighbors) + 1) for r in recv_neighbors
          }
          optimizer.self_weight = 1 / (len(recv_neighbors) + 1)
          optimizer.enable_topo_check = False
      elif args.dist_optimizer == "hierarchical_neighbor_allreduce":
          send_machines, recv_machines = next(
              dynamic_machine_neighbor_allreduce_gen
          )
          optimizer.dst_machine_weights = send_machines
          optimizer.src_machine_weights = {
              r: 1 / (len(recv_machines) + 1) for r in recv_machines
          }
          optimizer.self_weight = 1 / (len(recv_machines) + 1)
          optimizer.enable_topo_check = False
      else:
          pass
  
file_path: bluefog/examples/pytorch_benchmark.py
imports: import argparse
  import timeit
  import numpy
  import torch
  import torch.backends.cudnn
  from torch import nn
  import torch.nn.functional
  import torch.optim
  import torch.utils.data.distributed
  from torchvision import models
  import bluefog.torch
  from bluefog.common import topology_util
label_desc: Use image node_id 1 for calling a global function with example usage: dynamic_topology_update(batch_idx) without return types