docstr: Creates the shared tensor from the input `tensor` provided by party `src`.
  The `ptype` defines the type of sharing used (default: arithmetic).
  
  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","`","ptype","`","defines","the","type","of","sharing","used","(","default",":","arithmetic",")",".","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,
      ctx,
      tensor,
      ptype=Ptype.arithmetic,
      device=None,
      *args,
      **kwargs,
  ):
      """
      Creates the shared tensor from the input `tensor` provided by party `src`.
      The `ptype` defines the type of sharing used (default: arithmetic).
  
      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`.
      """
      # if tensor is None:
      #     raise ValueError("Cannot initialize tensor with None.")
  
      # take required_grad from kwargs, input tensor, or set to False:
      default = (
          tensor.requires_grad if torch.is_tensor(tensor) else False
      )
      requires_grad = kwargs.pop("requires_grad", default)
  
      # call CrypTensor constructor:
      super().__init__(requires_grad=requires_grad)
      if device is None and hasattr(tensor, "device"):
          device = tensor.device
  
      # create the MPCTensor:
      if tensor is []:
          self._tensor = torch.tensor([], device=device)
      else:
          tensor_type = ptype.to_tensor()
          self._tensor = tensor_type(
              ctx=ctx, tensor=tensor, device=device, *args, **kwargs
          )
      self.ptype = ptype
      self.ctx = ctx
  
imports: import torch
  from .None import communicator
  from .common.tensor_types import is_tensor
  from .common.util import torch_stack
  from .config import cfg
  from .cryptensor import CrypTensor
  from .cuda import CUDALongTensor
  from .encoder import FixedPointEncoder
  from .primitives.binary import BinarySharedTensor
  from .primitives.converters import convert
  from .ptype import ptype
label_desc: Use image node_id 1 to create a new MPCTensor object from inherited base classes: CrypTensor with example: obj = MPCTensor(ctx, tensor, ptype, device)