code: def test_offline_mode_pipeline_exception(self):
      load = """
  from transformers import pipeline
          """
      run = """
  mname = "hf-internal-testing/tiny-random-bert"
  pipe = pipeline(model=mname)
          """
  
      mock = """
  import socket
  def offline_socket(*args, **kwargs): raise socket.error("Offline mode is enabled")
  socket.socket = offline_socket
          """
      env = self.get_env()
      env["TRANSFORMERS_OFFLINE"] = "1"
      cmd = [sys.executable, "-c", "\n".join([load, mock, run])]
      result = subprocess.run(
          cmd, env=env, check=False, capture_output=True
      )
      self.assertEqual(result.returncode, 1, result.stderr)
      self.assertIn(
          "You cannot infer task automatically within `pipeline` when using offline mode",
          result.stderr.decode().replace("\n", ""),
      )
  
file_path: transformers/tests/utils/test_offline.py
imports: import subprocess
  import sys
  from transformers import BertConfig, BertModel, BertTokenizer, pipeline
  from transformers.testing_utils import TestCasePlus, require_torch
label_desc: Use image node_id 4 for calling the OfflineTests obj's underlying member method code with example usage: obj.test_offline_mode_pipeline_exception() without return types