code: def test_patterns(pattern):
      """
      Testing NetGear different messaging patterns
      """
      # define parameters
      options = {
          "flag": 0,
          "copy": False,
          "track": False,
          "jpeg_compression": False,
          "subscriber_timeout": 5,
      }
      # initialize
      frame_server = None
      stream = None
      server = None
      client = None
      try:
          # open stream
          stream = cv2.VideoCapture(return_testvideo_path())
          client = NetGear(
              pattern=pattern,
              receive_mode=True,
              logging=True,
              **options,
          )
          server = NetGear(pattern=pattern, logging=True, **options)
          # select random input frame from stream
          i = 0
          random_cutoff = random.randint(10, 100)
          while i < random_cutoff:
              (grabbed, frame_server) = stream.read()
              i += 1
          # check if input frame is valid
          assert not (frame_server is None)
          # send frame over network
          server.send(frame_server)
          frame_client = client.recv(
              return_data=[1, 2, 3] if pattern == 2 else None
          )
          # check if received frame exactly matches input frame
          assert np.array_equal(frame_server, frame_client)
      except Exception as e:
          if isinstance(e, (ZMQError, ValueError, RuntimeError)):
              logger.exception(str(e))
          else:
              pytest.fail(str(e))
      finally:
          # clean resources
          if not (stream is None):
              stream.release()
          if not (server is None):
              server.close(kill=True)
          if not (client is None):
              client.close(kill=True)
  
imports: import os
  import platform
  import queue
  import cv2
  import numpy
  import pytest
  import random
  import logging
  import tempfile
  from zmq.error import ZMQError
  from vidgear.gears import NetGear, VideoGear
  from vidgear.gears.helper import logger_handler
label_desc: Use image node_id 4 for calling a global function with example usage: test_patterns(pattern) without return types