parameters: (
          self, device: Optional[torch.device] = None, memo: Optional[Set] = None
      )
docstring: Move all buffers to the given *device*.
          If *device* is not given, then it will default to
          ``self.compute_device``. In the
          case of nested FSDP instances, we will respect the child instance's
          ``compute_device`` configuration.
          Args:
              device (torch.device, Optional):
                  device to cast buffers to (defaults to compute_device)
              memo (Set, Optional):
                  set of modules that have already been processed
docstring_summary: Move all buffers to the given *device*.
          If *device* is not given, then it will default to
          ``self.compute_device``. In the
          case of nested FSDP instances, we will respect the child instance's
          ``compute_device`` configuration.
          Args:
              device (torch.device, Optional):
                  device to cast buffers to (defaults to compute_device)
              memo (Set, Optional):
                  set of modules that have already been processed
docstring_tokens: Move all buffers to the given * device * . If * device * is not given then it will default to self . compute_device . In the case of nested FSDP instances we will respect the child instance s compute_device configuration . Args : device ( torch . device Optional ) : device to cast buffers to ( defaults to compute_device ) memo ( Set Optional ) : set of modules that have already been processed
function: def _cast_buffers(
          self, device: Optional[torch.device] = None, memo: Optional[Set] = None
      ) -> None:
          """Move all buffers to the given *device*.
          If *device* is not given, then it will default to
          ``self.compute_device``. In the
          case of nested FSDP instances, we will respect the child instance's
          ``compute_device`` configuration.
          Args:
              device (torch.device, Optional):
                  device to cast buffers to (defaults to compute_device)
              memo (Set, Optional):
                  set of modules that have already been processed
          """
          if memo is None:
              memo = set()
          for module in self.modules():
              if module is not self and isinstance(module, FullyShardedDataParallel):
                  # Allow any child FSDP instances to handle their own buffers.
                  module._cast_buffers(device=device, memo=memo)
              elif module not in memo:
                  memo.add(module)
                  for name, buf in module.named_buffers(recurse=False):
                      if buf is None:
                          continue
                      buf = buf.to(device=device or self.compute_device)
                      setattr(module, name, buf)
function_tokens: def _cast_buffers ( self , device : Optional [ torch . device ] = None , memo : Optional [ Set ] = None ) -> None : if memo is None : memo = set ( ) for module in self . modules ( ) : if module is not self and isinstance ( module , FullyShardedDataParallel ) : # Allow any child FSDP instances to handle their own buffers. module . _cast_buffers ( device = device , memo = memo ) elif module not in memo : memo . add ( module ) for name , buf in module . named_buffers ( recurse = False ) : if buf is None : continue buf = buf . to ( device = device or self . compute_device ) setattr ( module , name , buf )