code: def __init__(
      self,
      num_clients: int,
      nparts_lhs: int,
      nparts_rhs: int,
      entities_lhs: Set[EntityName],
      entities_rhs: Set[EntityName],
      entity_counts: Dict[str, List[int]],
      init_tree: bool,
      stats_handler: StatsHandler,
  ) -> None:
      super().__init__(num_clients)
      self.nparts_lhs: int = nparts_lhs
      self.nparts_rhs: int = nparts_rhs
      self.entities_lhs: Set[EntityName] = entities_lhs
      self.entities_rhs: Set[EntityName] = entities_rhs
      # We need the entity counts to estimate the I/O cost of switching from
      # one bucket to another (due to saving and loading the checkpoints of
      # the embeddings that are not in common). We don't want small variations
      # in the embedding table sizes to always force a certain bucket order;
      # instead we'd like to keep some randomness among the buckets that are
      # effectively equivalent to ensure good mixing. So we replace the counts
      # by the average of all the counts of a certain entity, as they all
      # follow the same distribution.
      self.average_entity_counts: Dict[str, int] = {
          entity: round(mean(counts))
          for entity, counts in entity_counts.items()
      }
      self.init_tree = init_tree
      self.stats_handler = stats_handler
  
      self.active: Dict[Bucket, Rank] = {}
      self.done: Set[Bucket] = set()
      self.dirty: Set[Tuple[EntityName, Partition]] = set()
      self.stats: List[BucketStats] = []
      self.initialized_entities_partitions: Optional[
          Set[Tuple[EntityName, Partition]]
      ] = None
  
imports: import logging
  import random
  from abc import ABC, abstractmethod
  from collections import defaultdict
  from statistics import mean
  from typing import Dict, List, NamedTuple, Optional, Set, Tuple
  from torchbiggraph.config import BucketOrder
  from torchbiggraph.distributed import Startable
  from torchbiggraph.rpc import Client, Server
  from torchbiggraph.stats import Stats, StatsHandler
  from torchbiggraph.types import Bucket, EntityName, Partition, Rank, Side
label_desc: Use image node_id 1 to create a new LockServer object from inherited base classes: Server, Startable with example: obj = LockServer(num_clients, nparts_lhs, nparts_rhs, entities_lhs, entities_rhs, entity_counts, init_tree, stats_handler)