code: def convert_inf(
      x: Optional[Union[int, float]]
  ) -> Optional[Union[int, float]]:
      """The tqdm doesn't support inf/nan values.
  
      We have to convert it to None.
  
      """
      if x is None or math.isinf(x) or math.isnan(x):
          return None
      return x
  
imports: import importlib
  import math
  import os
  import sys
  from typing import Any, Dict, Optional, Union
  from typing_extensions import override
  from lightning.pytorch.utilities.types import STEP_OUTPUT
  import lightning.pytorch
  from lightning.pytorch.callbacks.progress.progress_bar import ProgressBar
  from lightning.pytorch.utilities.rank_zero import rank_zero_debug
label_desc: Use image node_id 1 for calling a global function with example usage: convert_inf(x) and returns: x, None