class_docstr: Utility class that declares and fetches averaging-related keys using a DHT
class_docstr_tok: ["Utility","class","that","declares","and","fetches","averaging-related","keys","using","a","DHT"]
code: def __init__(
      self,
      dht: DHT,
      prefix: str,
      initial_group_bits: str,
      target_group_size: Optional[int],
  ):
      assert all(bit in "01" for bit in initial_group_bits)
      if target_group_size is not None and not is_power_of_two(
          target_group_size
      ):
          logger.warning(
              "It is recommended to set target_group_size to a power of 2"
          )
  
      self.dht, self.prefix, self.group_bits = (
          dht,
          prefix,
          initial_group_bits,
      )
      self.target_group_size = target_group_size
      self.peer_id = dht.peer_id
  
file_path: hivemind/hivemind/averaging/key_manager.py
imports: import random
  import re
  from typing import List, Optional, Tuple
  import numpy
  from hivemind.averaging.group_info import GroupInfo
  from hivemind.dht import DHT
  from hivemind.p2p import PeerID
  from hivemind.utils import DHTExpiration, get_logger
label_desc: Use image node_id 1 to create a new GroupKeyManager object  with example: obj = GroupKeyManager(dht, prefix, initial_group_bits, target_group_size)