def __init__()

in realbook/callbacks/utilization.py [0:0]


    def __init__(self, tensorboard_writer: tf.summary.SummaryWriter, poll_period_seconds: float = 30):
        """
        A base class that can be used to create callbacks for measuring utilization of some resource.
        To override, override RESOURCE_NAME and resource_fn. resource_fn is a function that measures
        some resource and returns a percentage translating to amount utilized.

        This callback is not meant to be used in distributed training environments.

        Args:
            tensorboard_writer: A tensorboard SummaryWriter to write scalar summary events to.
            poll_period_seconds: The period (in seconds) at which to poll the resource.
        """
        if self.RESOURCE_NAME == "":
            raise ValueError("RESOURCE_NAME must be specified. Did you forget to overwrite it?")
        self.tensorboard_writer = tensorboard_writer
        # TF Can't really serialize objects for multiprocessing so...we get threads!
        self.measurement_thread = threading.Thread(
            target=self.measurement_poller,
            args=(
                self.tensorboard_writer,
                self.resource_fn,
                self.RESOURCE_NAME,
                poll_period_seconds,
            ),
            daemon=True,
        )
        self.finished = False