code: def test_comet_metrics_safe(comet_mock, tmp_path, monkeypatch):
      """Test that CometLogger.log_metrics doesn't do inplace modification of metrics."""
      _patch_comet_atexit(monkeypatch)
      logger = CometLogger(project_name="test", save_dir=str(tmp_path))
      metrics = {
          "tensor": tensor(
              [[1.0, 0.0], [0.0, 1.0]], requires_grad=True
          ),
          "epoch": 1,
      }
      logger.log_metrics(metrics)
      assert metrics["tensor"].requires_grad
  
imports: import os
  from unittest import mock
  from unittest.mock import DEFAULT, Mock, patch
  import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loggers import CometLogger
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch import tensor
label_desc: Use image node_id 11 for calling a global function with example usage: test_comet_metrics_safe(comet_mock, tmp_path, monkeypatch) without return types