class_docstr: Computes throughput.
  
  This class will automatically keep a count of the number of log calls (``step``). But that can be modified as
  desired. For manual logging, using :class:`Throughput` directly might be desired.
  
  Example::
  
      logger = ...
      fabric = Fabric(logger=logger)
      throughput = ThroughputMonitor()
      t0 = time()
      for i in range(1, 100):
          do_work()
          if torch.cuda.is_available(): torch.cuda.synchronize()  # required or else time() won't be correct
          throughput.update(time=time() - t0, batches=i, samples=i)
          if i % 10 == 0:
              throughput.compute_and_log(step=i)
  
  Args:
      fabric: The Fabric object.
      \**kwargs: See available parameters in :class:`Throughput`
docstr: See :meth:`Throughput.compute`
  
  Args:
      step: Can be used to override the logging step.
      \**kwargs: See available parameters in :meth:`Throughput.compute`
docstr_tok: ["See",":","meth",":","`","Throughput.compute","`","Args",":","step",":","Can","be","used","to","override","the","logging","step",".","\\","*","*","kwargs",":","See","available","parameters","in",":","meth",":","`","Throughput.compute","`"]
code: def compute_and_log(
      self, step: Optional[int] = None, **kwargs: Any
  ) -> _THROUGHPUT_METRICS:
      r"""See :meth:`Throughput.compute`
  
      Args:
          step: Can be used to override the logging step.
          \**kwargs: See available parameters in :meth:`Throughput.compute`
  
      """
      self.step = (self.step + 1) if step is None else step
      metrics = self.compute(**kwargs)
      self._fabric.log_dict(metrics=metrics, step=self.step)
      return metrics
  
imports: from collections import deque
  from typing import TYPE_CHECKING, Any, Callable, Deque, Dict, List, Optional, TypeVar, Union
  import torch
  from typing_extensions import override
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from lightning.fabric.utilities.rank_zero import rank_zero_only, rank_zero_warn
label_desc: Use image node_id 2 for calling the ThroughputMonitor obj's underlying member method code with example usage: obj.compute_and_log(step) and returns: metrics