code: def rank_zero_only(fn: Callable) -> Callable:
      """Decorator function from PyTorch Lightning.
  
      Function that can be used as a decorator
      to enable a function/method being called only on global rank 0.
      """
  
      @wraps(fn)
      def wrapped_fn(*args: Any, **kwargs: Any) -> Optional[Any]:
          if rank_zero_only.rank == 0:
              return fn(*args, **kwargs)
          return None
  
      return wrapped_fn
  
imports: import logging
  import math
  import os
  from functools import wraps
  from typing import Any, Callable, Optional
  import numpy
  import opt_einsum
  import torch
  import torch.nn
  import torch.nn.functional
  from einops import rearrange, repeat
  from espnet2.asr.state_spaces.components import Activation, DropoutNd, LinearActivation
label_desc: Use image node_id 1 for calling a global function with example usage: rank_zero_only(fn) and returns: wrapped_fn, None, fn