code: def _shortcut_patch(orig_fn, shortcut_case, attr_names=None):
      """Patch a function to return False value in the shortcut case, otherwise return original value."""
  
      def new_fn(*args, **kwargs):
          if attr_names is not None:
              # We assume that the first argument is the object to check and therefore values are stored in attributes.
              self = args[0]
              values = tuple(
                  getattr(self, attr_name) for attr_name in attr_names
              )
          else:
              values = args
          match = True
          for value, case in zip(values, shortcut_case):
              # Go through values passed to the original function and compare them to the shortcut case.
              # We are iterating in case the `shortcut_case` and `args` lengths are different.
              if value != case:
                  match = False
                  break
          if (
              match
          ):  # If all values match the shortcut case, return False to simulate the module not being available.
              return False
          # otherwise return the original value
          return orig_fn(*args, **kwargs)
  
      return new_fn
  
file_path: pytorch-lightning/tests/tests_pytorch/utilities/test_imports.py
imports: import importlib
  import subprocess
  import sys
  from textwrap import dedent
  from unittest import mock
  import pytest
  from lightning.pytorch.utilities.imports import _OMEGACONF_AVAILABLE
  from lightning_utilities.core.imports import RequirementCache
  from torch.distributed import is_available
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 2 for calling a global function with example usage: _shortcut_patch(orig_fn, shortcut_case, attr_names) and returns: new_fn, orig_fn, False