def _start_profiler(self, logdir):
        """Starts the profiler if currently inactive.

        Args:
          logdir: Directory where profiler results will be saved.
        """
        if self._profiler_started:
            return
        try:
            backend.tensorboard.start_trace(logdir)
            self._profiler_started = True
        except Exception as e:
            # Profiler errors should not be fatal.
            logging.error("Failed to start profiler: %s", e)
Starts the profiler if currently inactive.

        Args:
          logdir: Directory where profiler results will be saved.
        
keras/src/callbacks/tensorboard.py