code: def templateGridFourConnectionsTest(self, network):
      assert network.structure == conn_type.GRID_FOUR
  
      for index in range(0, len(network), 1):
          upper_index = index - network.width
          lower_index = index + network.width
          left_index = index - 1
          right_index = index + 1
  
          node_row_index = math.ceil(index / network.width)
          if upper_index >= 0:
              assert network.has_connection(index, upper_index) == True
              assert network.has_connection(upper_index, index) == True
  
          if lower_index < len(network):
              assert network.has_connection(index, lower_index) == True
              assert network.has_connection(lower_index, index) == True
  
          if (left_index >= 0) and (
              math.ceil(left_index / network.width) == node_row_index
          ):
              assert network.has_connection(index, left_index) == True
              assert network.has_connection(left_index, index) == True
  
          if (right_index < network._num_osc) and (
              math.ceil(right_index / network.width) == node_row_index
          ):
              assert network.has_connection(index, right_index) == True
              assert network.has_connection(right_index, index) == True
  
imports: import unittest
  import math
  from pyclustering.nnet import network, conn_type, conn_represent
label_desc: Use image node_id 14 for calling the NnetUnitTest obj's underlying member method code with example usage: obj.templateGridFourConnectionsTest(network) without return types