def add_image(self, image: np.ndarray | Figure, name: str | None = None, **kwargs) -> None:
        """Log images to TensorBoard.

        Args:
            image: Image to log, can be either a numpy array or matplotlib
                Figure.
            name: Name/title of the image. Defaults to ``None``.
            **kwargs: Must contain ``global_step`` (int) indicating the step at
                which to log the image. Additional keyword arguments are passed
                to the TensorBoard logging method.

        Raises:
            ValueError: If ``global_step`` is not provided in ``kwargs``.
        """
        if "global_step" not in kwargs:
            msg = "`global_step` is required for tensorboard logger"
            raise ValueError(msg)

        # Need to call different functions of `SummaryWriter` for  Figure vs np.ndarray
        if isinstance(image, Figure):
            self.experiment.add_figure(figure=image, tag=name, close=False, **kwargs)
        else:
            self.experiment.add_image(img_tensor=image, tag=name, dataformats="HWC", **kwargs)
Log images to TensorBoard.

        Args:
            image: Image to log, can be either a numpy array or matplotlib
                Figure.
            name: Name/title of the image. Defaults to ``None``.
            **kwargs: Must contain ``global_step`` (int) indicating the step at
                which to log the image. Additional keyword arguments are passed
                to the TensorBoard logging method.

        Raises:
            ValueError: If ``global_step`` is not provided in ``kwargs``.
        
src/anomalib/loggers/tensorboard.py