class_docstr: Encrypted tensor object that uses binary sharing to perform computations.
  
  Binary shares are computed by splitting each value of the input tensor
  into n separate random values that xor together to the input tensor value,
  where n is the number of parties present in the protocol (world_size).
class_docstr_tok: ["Encrypted","tensor","object","that","uses","binary","sharing","to","perform","computations",".","Binary","shares","are","computed","by","splitting","each","value","of","the","input","tensor","into","n","separate","random","values","that","xor","together","to","the","input","tensor","value",",","where","n","is","the","number","of","parties","present","in","the","protocol","(","world_size",")","."]
docstr: Creates the shared tensor from the input `tensor` provided by party `src`.
  
  The other parties can specify a `tensor` or `size` to determine the size
  of the shared tensor object to create. In this case, all parties must
  specify the same (tensor) size to prevent the party's shares from varying
  in size, which leads to undefined behavior.
  
  Alternatively, the parties can set `broadcast_size` to `True` to have the
  `src` party broadcast the correct size. The parties who do not know the
  tensor size beforehand can provide an empty tensor as input. This is
  guaranteed to produce correct behavior but requires an additional
  communication round.
  
  The parties can also set the `precision` and `device` for their share of
  the tensor. If `device` is unspecified, it is set to `tensor.device`.
docstr_tok: ["Creates","the","shared","tensor","from","the","input","`","tensor","`","provided","by","party","`","src","`",".","The","other","parties","can","specify","a","`","tensor","`","or","`","size","`","to","determine","the","size","of","the","shared","tensor","object","to","create",".","In","this","case",",","all","parties","must","specify","the","same","(","tensor",")","size","to","prevent","the","party","'s","shares","from","varying","in","size",",","which","leads","to","undefined","behavior",".","Alternatively",",","the","parties","can","set","`","broadcast_size","`","to","`","True","`","to","have","the","`","src","`","party","broadcast","the","correct","size",".","The","parties","who","do","not","know","the","tensor","size","beforehand","can","provide","an","empty","tensor","as","input",".","This","is","guaranteed","to","produce","correct","behavior","but","requires","an","additional","communication","round",".","The","parties","can","also","set","the","`","precision","`","and","`","device","`","for","their","share","of","the","tensor",".","If","`","device","`","is","unspecified",",","it","is","set","to","`","tensor.device","`","."]
code: def __init__(
      self,
      tensor=None,
      size=None,
      broadcast_size=False,
      src=0,
      device=None,
  ):
      """
      Creates the shared tensor from the input `tensor` provided by party `src`.
  
      The other parties can specify a `tensor` or `size` to determine the size
      of the shared tensor object to create. In this case, all parties must
      specify the same (tensor) size to prevent the party's shares from varying
      in size, which leads to undefined behavior.
  
      Alternatively, the parties can set `broadcast_size` to `True` to have the
      `src` party broadcast the correct size. The parties who do not know the
      tensor size beforehand can provide an empty tensor as input. This is
      guaranteed to produce correct behavior but requires an additional
      communication round.
  
      The parties can also set the `precision` and `device` for their share of
      the tensor. If `device` is unspecified, it is set to `tensor.device`.
      """
  
      # do nothing if source is sentinel:
      if src == SENTINEL:
          return
  
      # assertions on inputs:
      assert (
          isinstance(src, int)
          and src >= 0
          and src < comm.get().get_world_size()
      ), "specified source party does not exist"
      if self.rank == src:
          assert tensor is not None, "source must provide a data tensor"
          if hasattr(tensor, "src"):
              assert (
                  tensor.src == src
              ), "source of data tensor must match source of encryption"
      if not broadcast_size:
          assert (
              tensor is not None or size is not None
          ), "must specify tensor or size, or set broadcast_size"
  
      # if device is unspecified, try and get it from tensor:
      if (
          device is None
          and tensor is not None
          and hasattr(tensor, "device")
      ):
          device = tensor.device
  
      # assume zero bits of precision unless encoder is set outside of init:
      self.encoder = FixedPointEncoder(precision_bits=0)
      if tensor is not None:
          tensor = self.encoder.encode(tensor)
          tensor = tensor.to(device=device)
          size = tensor.size()
  
      # if other parties do not know tensor's size, broadcast the size:
      if broadcast_size:
          size = comm.get().broadcast_obj(size, src)
  
      # generate pseudo-random zero sharing (PRZS) and add source's tensor:
      self.share = BinarySharedTensor.PRZS(size, device=device).share
      if self.rank == src:
          self.share ^= tensor
  
imports: import crypten.communicator
  import torch
  from crypten.common.functions import regular
  from crypten.common.rng import generate_kbit_random_tensor
  from crypten.common.tensor_types import is_tensor
  from crypten.common.util import torch_cat, torch_stack
  from crypten.cuda import CUDALongTensor
  from crypten.encoder import FixedPointEncoder
  from .None import beaver, circuit
label_desc: Use image node_id 1 to create a new BinarySharedTensor object  with example: obj = BinarySharedTensor(tensor, size, broadcast_size, src, device)