original_docstring: Map MXNet's _linalg_gemm2 operator attributes to onnx's
      MatMul and Transpose operators based on the values set for
      transpose_a, transpose_b attributes.
      Return multiple nodes created.
      
docstring: Map MXNet's _linalg_gemm2 operator attributes to onnx's
  MatMul and Transpose operators based on the values set for
  transpose_a, transpose_b attributes.
  Return multiple nodes created.
docstring_tokens: Map MXNet ' s _linalg_gemm2 operator attributes to onnx ' s MatMul and Transpose operators based on the values set for transpose_a transpose_b attributes . Return multiple nodes created .
code: def convert_linalg_gemm2(node, **kwargs):
      """Map MXNet's _linalg_gemm2 operator attributes to onnx's
      MatMul and Transpose operators based on the values set for
      transpose_a, transpose_b attributes.
      Return multiple nodes created.
      """
      onnx = import_onnx_modules()
      proc_nodes = kwargs["proc_nodes"]
      node_inputs = node["inputs"]
      name = node["name"]
  
      input_a_idx = kwargs["index_lookup"][node_inputs[0][0]]
      input_node_a = proc_nodes[input_a_idx].name
      input_b_idx = kwargs["index_lookup"][node_inputs[1][0]]
      input_node_b = proc_nodes[input_b_idx].name
  
      # Getting the attributes and assigning default values.
      if "attrs" in node:
          attrs = node["attrs"]
          alpha = float(attrs["alpha"])
          trans_a = int(attrs["transpose_a"])
          trans_b = int(attrs["transpose_b"])
      else:
          alpha = 1.0
          trans_a = 0
          trans_b = 0
  
      op_name = "transpose" + str(kwargs["idx"])
  
      if alpha == 1.0 and trans_a == 0 and trans_b == 0:
          matmul_node = onnx.helper.make_node(
              'MatMul',
              inputs=[input_node_a, input_node_b],
              outputs=[name],
              name=name
          )
          return [matmul_node]
      elif trans_a == 1 and trans_b == 0:
          op_name = "transpose" + str(kwargs["idx"])
          node_name = op_name+"_a"
          trans_a_node = onnx.helper.make_node(
              'Transpose',
              inputs=[input_node_a],
              outputs=[op_name+"_a"],
              name=node_name
          )
  
          matmul_node = onnx.helper.make_node(
              'MatMul',
              inputs=[node_name, input_node_b],
              outputs=[name],
              name=name
          )
          return [trans_a_node, matmul_node]
  
      elif trans_a == 0 and trans_b == 1:
          node_name = op_name + "_b"
          trans_b_node = onnx.helper.make_node(
              'Transpose',
              inputs=[input_node_b],
              outputs=[op_name+"_b"],
              name=node_name
          )
  
          matmul_node = onnx.helper.make_node(
              'MatMul',
              inputs=[input_node_a, node_name],
              outputs=[name],
              name=name
          )
  
          return [trans_b_node, matmul_node]
      else:
          node_name_a = op_name+"_a"
          trans_a_node = onnx.helper.make_node(
              'Transpose',
              inputs=[input_node_a],
              outputs=[op_name+"_a"],
              name=node_name_a
          )
  
          node_name_b = op_name + "_b"
          trans_b_node = onnx.helper.make_node(
              'Transpose',
              inputs=[input_node_b],
              outputs=[op_name+"_b"],
              name=node_name_b
          )
  
          matmul_node = onnx.helper.make_node(
              'MatMul',
              inputs=[node_name_a, node_name_b],
              outputs=[name],
              name=name
          )
  
          return [trans_a_node, trans_b_node, matmul_node]
code_tokens: def convert_linalg_gemm2 ( node , ** kwargs ) : onnx = import_onnx_modules ( ) proc_nodes = kwargs [ "proc_nodes" ] node_inputs = node [ "inputs" ] name = node [ "name" ] input_a_idx = kwargs [ "index_lookup" ] [ node_inputs [ 0 ] [ 0 ] ] input_node_a = proc_nodes [ input_a_idx ] . name input_b_idx = kwargs [ "index_lookup" ] [ node_inputs [ 1 ] [ 0 ] ] input_node_b = proc_nodes [ input_b_idx ] . name if "attrs" in node : attrs = node [ "attrs" ] alpha = float ( attrs [ "alpha" ] ) trans_a = int ( attrs [ "transpose_a" ] ) trans_b = int ( attrs [ "transpose_b" ] ) else : alpha = 1.0 trans_a = 0 trans_b = 0 op_name = "transpose" + str ( kwargs [ "idx" ] ) if alpha == 1.0 and trans_a == 0 and trans_b == 0 : matmul_node = onnx . helper . make_node ( 'MatMul' , inputs = [ input_node_a , input_node_b ] , outputs = [ name ] , name = name ) return [ matmul_node ] elif trans_a == 1 and trans_b == 0 : op_name = "transpose" + str ( kwargs [ "idx" ] ) node_name = op_name + "_a" trans_a_node = onnx . helper . make_node ( 'Transpose' , inputs = [ input_node_a ] , outputs = [ op_name + "_a" ] , name = node_name ) matmul_node = onnx . helper . make_node ( 'MatMul' , inputs = [ node_name , input_node_b ] , outputs = [ name ] , name = name ) return [ trans_a_node , matmul_node ] elif trans_a == 0 and trans_b == 1 : node_name = op_name + "_b" trans_b_node = onnx . helper . make_node ( 'Transpose' , inputs = [ input_node_b ] , outputs = [ op_name + "_b" ] , name = node_name ) matmul_node = onnx . helper . make_node ( 'MatMul' , inputs = [ input_node_a , node_name ] , outputs = [ name ] , name = name ) return [ trans_b_node , matmul_node ] else : node_name_a = op_name + "_a" trans_a_node = onnx . helper . make_node ( 'Transpose' , inputs = [ input_node_a ] , outputs = [ op_name + "_a" ] , name = node_name_a ) node_name_b = op_name + "_b" trans_b_node = onnx . helper . make_node ( 'Transpose' , inputs = [ input_node_b ] , outputs = [ op_name + "_b" ] , name = node_name_b ) matmul_node = onnx . helper . make_node ( 'MatMul' , inputs = [ node_name_a , node_name_b ] , outputs = [ name ] , name = name ) return [ trans_a_node , trans_b_node , matmul_node ]
short_docstring: Map MXNet's _linalg_gemm2 operator attributes to onnx's
  MatMul and Transpose operators based on the values set for
  transpose_a, transpose_b attributes.
short_docstring_tokens: Map MXNet ' s _linalg_gemm2 operator attributes to onnx ' s MatMul and Transpose operators based on the values set for transpose_a transpose_b attributes .
comment: """Map MXNet's _linalg_gemm2 operator attributes to onnx's
      MatMul and Transpose operators based on the values set for
      transpose_a, transpose_b attributes.
      Return multiple nodes created.
      """$SEP$# Getting the attributes and assigning default values.