class_docstr: Client for ParameterServer.
  Supports store, accumulate, swap, swap-accumulate, and get operations.
class_docstr_tok: ["Client","for","ParameterServer",".","Supports","store",",","accumulate",",","swap",",","swap-accumulate",",","and","get","operations","."]
docstr: Store or accumulate a tensor on the server,
  and then get its current value.
code: def swap(
      self,
      key: str,
      src: torch.Tensor,
      dst: Optional[torch.Tensor] = None,
      accum: bool = False,
      overwrite: bool = False,
  ) -> None:
      """Store or accumulate a tensor on the server,
      and then get its current value.
      """
      self._validate_swap(
          key, src, dst=dst, accum=accum, overwrite=overwrite
      )
      if dst is None:
          dst = torch.zeros_like(src)
  
      cmd_rpc = torch.tensor(
          [
              SWAP_CMD,
              len(key),
              -1 if accum else src.ndimension(),
              int(accum),
              int(overwrite),
              _dtypes.index(src.dtype),
          ],
          dtype=torch.long,
      )
      td.send(cmd_rpc, self.server_rank)
      td.send(_fromstring(key), self.server_rank)
      if not accum:
          td.send(
              torch.tensor(list(src.size()), dtype=torch.long),
              self.server_rank,
          )
      start_t = time.monotonic()
      td.send(src, self.server_rank)
      td.recv(dst, src=self.server_rank)
      end_t = time.monotonic()
      if self.log_stats:
          stats_size = (
              src.numel() * src.element_size()
              + dst.numel() * dst.element_size()
          )
          stats_time = end_t - start_t
          logger.debug(
              f"Swapped tensor {key} with server {self.server_rank}: "
              f"{stats_size:,} bytes "
              f"in {stats_time:,g} seconds "
              f"=> {stats_size / stats_time:,.0f} B/s"
          )
  
imports: import logging
  import multiprocessing
  import queue
  import time
  import traceback
  from functools import lru_cache
  from typing import Callable, Dict, List, Optional, Sequence
  import torch
  import torch.distributed
  import torch.multiprocessing
  from torchbiggraph.distributed import init_process_group, Startable
  from torchbiggraph.types import CharTensorType, Rank
  from torchbiggraph.util import allocate_shared_tensor, split_almost_equally, tag_logs_with_process_name
label_desc: Use image node_id 9 for calling the ParameterClient obj's underlying member method code with example usage: obj.swap(key, src, dst, accum, overwrite) without return types