code: def __init__(
      self,
      ctx: Context,
      aggregator_name: str = None,
      aggregate_type="mean",
      sample_num=1,
      is_mock=True,
      require_grad=True,
      float_p="float64",
  ) -> None:
      super().__init__(ctx, aggregator_name)
      self._weight = 1.0
      self.aggregator_name = (
          "default" if aggregator_name is None else aggregator_name
      )
      self.require_grad = require_grad
  
      assert (
          float_p in TORCH_TENSOR_PRECISION
      ), "float_p should be one of {}".format(TORCH_TENSOR_PRECISION)
      self.float_p = float_p
  
      if sample_num <= 0 and not isinstance(sample_num, int):
          raise ValueError("sample_num should be int greater than 0")
  
      logger.info("computing weights")
      if aggregate_type not in AGGREGATE_TYPE:
          raise ValueError(
              "aggregate_type should be one of {}".format(
                  AGGREGATE_TYPE
              )
          )
      elif aggregate_type == "mean":
          ctx.arbiter.put(self.suffix["local_weight"](), 1.0)
          self._weight = ctx.arbiter.get(
              self.suffix["computed_weight"]()
          )
      elif aggregate_type == "sum":
          ctx.arbiter.put(self.suffix["local_weight"](), sample_num)
          self._weight = 1.0
      elif aggregate_type == "weighted_mean":
          if sample_num <= 0 or sample_num is None:
              raise ValueError(
                  "sample_num should be int greater than 0"
              )
          ctx.arbiter.put(self.suffix["local_weight"](), sample_num)
          self._weight = ctx.arbiter.get(
              self.suffix["computed_weight"]()
          )
  
      logger.info("aggregate weight is {}".format(self._weight))
  
      self.model_aggregator = sa_client(
          prefix=self.aggregator_name + "_model", is_mock=is_mock
      )
      self.model_aggregator.dh_exchange(
          ctx, [ctx.guest.rank, *ctx.hosts.ranks]
      )
      self.loss_aggregator = sa_client(
          prefix=self.aggregator_name + "_loss", is_mock=is_mock
      )
      self.loss_aggregator.dh_exchange(
          ctx, [ctx.guest.rank, *ctx.hosts.ranks]
      )
  
imports: import logging
  from typing import Optional
  import numpy
  import torch
  from fate.arch import Context
  from fate.arch.protocol.secure_aggregation._secure_aggregation import SecureAggregatorClient
  from fate.arch.protocol.secure_aggregation._secure_aggregation import SecureAggregatorServer
label_desc: Use image node_id 1 to create a new BaseAggregatorClient object from inherited base classes: Aggregator with example: obj = BaseAggregatorClient(ctx, aggregator_name, aggregate_type, sample_num, is_mock, require_grad, float_p)