parameters: (graph: Graph, nodes: list)
docstring: When the first operation in the matched list is the Transpose then add the Reshape operation which reshapes to the
          Transpose input shape. This Reshape op is needed for the optimization pass. If the optimization will not be
          applied then this dummy Reshape will be removed by the "RemoveRedundantReshapes" pass.
  
          :param graph: the graph with nodes
          :param nodes: the sequence of Transpose and ReshapeFF nodes
          :return: None
docstring_summary: When the first operation in the matched list is the Transpose then add the Reshape operation which reshapes to the
          Transpose input shape. This Reshape op is needed for the optimization pass. If the optimization will not be
          applied then this dummy Reshape will be removed by the "RemoveRedundantReshapes" pass.
docstring_tokens: When the first operation in the matched list is the Transpose then add the Reshape operation which reshapes to the Transpose input shape . This Reshape op is needed for the optimization pass . If the optimization will not be applied then this dummy Reshape will be removed by the RemoveRedundantReshapes pass .
function: def add_leading_and_trailing_reshape(graph: Graph, nodes: list):
          """
          When the first operation in the matched list is the Transpose then add the Reshape operation which reshapes to the
          Transpose input shape. This Reshape op is needed for the optimization pass. If the optimization will not be
          applied then this dummy Reshape will be removed by the "RemoveRedundantReshapes" pass.
  
          :param graph: the graph with nodes
          :param nodes: the sequence of Transpose and ReshapeFF nodes
          :return: None
          """
          # add leading Reshape
          if nodes[0].type == 'Transpose':
              dummy_reshape_node = create_op_node_with_second_input(
                  graph, Reshape, nodes[0].in_port(0).data.get_shape().copy(),
                  {'name': nodes[0].in_port(0).get_connection().get_source().node.id + '/Reshape'})
              dummy_reshape_node[__class__.OPTIMIZED_NODE_FLAG] = True
              nodes[0].in_port(0).get_connection().insert_node(dummy_reshape_node)
              nodes.insert(0, dummy_reshape_node)
              log.debug('Added Reshape op "{}" in the beginning of the permute-reshape sequence'.format(
                  dummy_reshape_node.soft_get('name')))
  
          # similarly add the Reshape op after the last Transpose op which reshapes to the Transpose output shape
          if nodes[-1].type == 'Transpose':
              dummy_reshape_node = create_op_node_with_second_input(
                  graph, Reshape, nodes[-1].out_port(0).data.get_shape().copy(),
                  {'name': nodes[0].out_port(0).get_connection().get_destination().node.id + '/Reshape'})
              dummy_reshape_node[__class__.OPTIMIZED_NODE_FLAG] = True
              nodes[-1].out_port(0).get_connection().insert_node(dummy_reshape_node)
              nodes.append(dummy_reshape_node)
              log.debug('Added Reshape op "{}" in the end of the permute-reshape sequence'.format(
                  dummy_reshape_node.soft_get('name')))
function_tokens: def add_leading_and_trailing_reshape ( graph : Graph , nodes : list ) : # add leading Reshape if nodes [ 0 ] . type == 'Transpose' : dummy_reshape_node = create_op_node_with_second_input ( graph , Reshape , nodes [ 0 ] . in_port ( 0 ) . data . get_shape ( ) . copy ( ) , { 'name' : nodes [ 0 ] . in_port ( 0 ) . get_connection ( ) . get_source ( ) . node . id + '/Reshape' } ) dummy_reshape_node [ __class__ . OPTIMIZED_NODE_FLAG ] = True nodes [ 0 ] . in_port ( 0 ) . get_connection ( ) . insert_node ( dummy_reshape_node ) nodes . insert ( 0 , dummy_reshape_node ) log . debug ( 'Added Reshape op "{}" in the beginning of the permute-reshape sequence' . format ( dummy_reshape_node . soft_get ( 'name' ) ) ) # similarly add the Reshape op after the last Transpose op which reshapes to the Transpose output shape if nodes [ - 1 ] . type == 'Transpose' : dummy_reshape_node = create_op_node_with_second_input ( graph , Reshape , nodes [ - 1 ] . out_port ( 0 ) . data . get_shape ( ) . copy ( ) , { 'name' : nodes [ 0 ] . out_port ( 0 ) . get_connection ( ) . get_destination ( ) . node . id + '/Reshape' } ) dummy_reshape_node [ __class__ . OPTIMIZED_NODE_FLAG ] = True nodes [ - 1 ] . out_port ( 0 ) . get_connection ( ) . insert_node ( dummy_reshape_node ) nodes . append ( dummy_reshape_node ) log . debug ( 'Added Reshape op "{}" in the end of the permute-reshape sequence' . format ( dummy_reshape_node . soft_get ( 'name' ) ) )