code: def buffer_sync(
      module: _torch.nn.Module,
      fmodule: _MonkeyPatchBase,
      device: _typing.Optional[_torch.device] = None,
  ) -> None:
      r"""One off sync (copy) of buffers in ``fmodule`` with those from ``module``."""
      for key, value in module._buffers.items():
          if not _torch.is_tensor(value):
              fmodule._buffers[key] = value
          elif device is None:
              fmodule._buffers[key] = value.clone().detach()
          else:
              fmodule._buffers[key] = value.clone().detach().to(device)
  
      for name, child in module._modules.items():
          if name in fmodule._modules:
              buffer_sync(child, fmodule._modules[name], device)
          else:
              raise KeyError(
                  "Did not find expected submodule "
                  "{} of monkey-patched module {}.".format(
                      name, fmodule
                  )
              )
  
imports: import abc
  from collections import OrderedDict
  from contextlib import contextmanager
  import typing
  import weakref
  import warnings
  import torch
  from .None import utils
label_desc: Use image node_id 3 for calling a global function with example usage: buffer_sync(module, fmodule, device) without return types