def _sample_record()

in iopath/common/event_logger.py [0:0]


    def _sample_record(self) -> bool:
        """
        Samples the current event and logs only when the count
        reaches logging interval.

        Returns:
            True: if this sample should be logged.
            False: otherwise.
        """
        evt_op = self._evt.get(self.OP_KEY)
        if evt_op is None:
            # No op is set. Let's log it.
            return True

        if evt_op not in self.sample_counts:
            self.sample_counts[evt_op] = 1
            return True

        self.sample_counts[evt_op] += 1
        if self.sample_counts[evt_op] > self.SAMPLING_PERIOD:
            # Let's log this and reset sanpling counter.
            self.sample_counts[evt_op] = 1
            return True

        # Skip this sample.
        return False