code: def _A2B(arithmetic_tensor):
      # first try memory-inefficient implementation that takes O(log P) rounds:
      try:
          binary_tensor = BinarySharedTensor.stack(
              [
                  BinarySharedTensor(arithmetic_tensor.share, src=i)
                  for i in range(comm.get().get_world_size())
              ]
          )
          binary_tensor = binary_tensor.sum(dim=0)
  
      # if we OOM, try memory-efficient implementation that uses O(P) rounds:
      except RuntimeError:
          binary_tensor = None
          for i in range(comm.get().get_world_size()):
              binary_share = BinarySharedTensor(
                  arithmetic_tensor.share, src=i
              )
              binary_tensor = (
                  binary_share
                  if i == 0
                  else binary_tensor + binary_share
              )
  
      # return the result:
      binary_tensor.encoder = arithmetic_tensor.encoder
      return binary_tensor
  
file_path: CrypTen/crypten/mpc/primitives/converters.py
imports: import crypten.communicator
  import torch
  from crypten.encoder import FixedPointEncoder
  from ..ptype import ptype
  from .None import beaver
  from .arithmetic import ArithmeticSharedTensor
  from .binary import BinarySharedTensor
label_desc: Use image node_id 1 for calling a global function with example usage: _A2B(arithmetic_tensor) and returns: binary_tensor