code: def convert_GetItem(
      func, opset_version, input_names, output_names, context
  ):
      x = func.inputs[0]
      axes, starts, ends, steps = [], [], [], []
      squeeze_idxs, unsqueeze_idxs = [], []
      skipped = 0  # when set ellipsis, need to skip index rolling
  
      prev_gathered_axis = -1
      gather_axis = -1
      gather_idx = (
          None  # when GatherND, set first array for broadcasting
      )
      gather_nd_idx = None
      is_used_slice_whole = (
          False  # GatherND does not support axis, need to care
      )
  
      for i, idx in enumerate(func.slices):
          # axis means the index of input x, adjust None and Ellipsis counts
          axis = i - len(unsqueeze_idxs) + skipped
          if isinstance(idx, slice):
              if (
                  idx.start is None
                  and idx.stop is None
                  and idx.step is None
              ):
                  is_used_slice_whole = True
                  continue
              axes.append(axis)
              step = 1 if idx.step is None else idx.step
              steps.append(step)
              if step < 0:
                  starts.append(
                      np.iinfo(np.int64).max
                      if idx.start is None
                      else idx.start
                  )
                  ends.append(
                      np.iinfo(np.int64).min
                      if idx.stop is None
                      else idx.stop
                  )
              else:
                  starts.append(0 if idx.start is None else idx.start)
                  ends.append(
                      np.iinfo(np.int64).max
                      if idx.stop is None
                      else idx.stop
                  )
          elif isinstance(idx, int):
              axes.append(axis)
              steps.append(1)
              if idx == -1:
                  starts.append(idx)
                  ends.append(np.iinfo(np.int64).max)
              else:
                  starts.append(idx)
                  ends.append(idx + 1)
              squeeze_idxs.append(axis)
          elif isinstance(idx, np.ndarray) and idx.ndim == 0:
              scalar_idx = idx.item()
              axes.append(axis)
              starts.append(scalar_idx)
              ends.append(scalar_idx + 1)
              steps.append(1)
              squeeze_idxs.append(axis)
          elif idx is None:
              unsqueeze_idxs.append(i - len(squeeze_idxs) + skipped)
          elif idx is Ellipsis:
              # calculate rest slice number except None, GetItem does not allow
              # multiple Ellipsis, so ignore latter Ellipsis count
              rest_slice_len = len(
                  [
                      idx_
                      for idx_ in func.slices[i + 1 :]
                      if idx_ is not None
                  ]
              )
              assert skipped == 0
              skipped = len(x.shape) - axis - rest_slice_len - 1
          elif isinstance(idx, (list,) + chainer.get_array_types()):
              if prev_gathered_axis >= 0:
                  if (i - 1) != prev_gathered_axis:
                      raise ValueError(
                          "ONNX-Chainer does not support non-consecutive"
                          "multiple advanced indexing"
                      )
                  if is_used_slice_whole:
                      raise ValueError(
                          "ONNX-Chainer does not support whole indexing(`[:]`)"
                          "in front of multiple advanced indexing"
                      )
                  if unsqueeze_idxs:
                      raise ValueError(
                          "ONNX-Chainer does not support new axis in front of "
                          "multiple advanced indexing"
                      )
                  # multiple advanced index, convert to GatherND
                  idx_array = _to_ndarray(idx)
                  base_idx = (
                      gather_idx
                      if gather_nd_idx is None
                      else gather_nd_idx
                  )
                  gather_nd_idx = np.vstack((base_idx, idx_array))
                  prev_gathered_axis = i
              else:
                  # convert to Gather, if next index is also list, change to
                  # GatherND
                  gather_axis = (
                      axis - len(squeeze_idxs) + len(unsqueeze_idxs)
                  )
                  gather_idx = _to_ndarray(idx)
                  prev_gathered_axis = i
          else:
              raise ValueError(
                  "GetItem with type {} cannot handle in ONNX Slice, so that "
                  "ONNX-Chainer does not accept the type".format(
                      type(idx)
                  )
              )
  
      gb = onnx_helper.GraphBuilder()
      slice_output = input_names
      if axes:
          output = get_slice_node(
              gb,
              opset_version,
              context,
              slice_output,
              axes,
              starts,
              ends,
              steps,
          )
          slice_output = [output]
      if squeeze_idxs:
          output = gb.op("Squeeze", slice_output, axes=squeeze_idxs)
          slice_output = [output]
      if unsqueeze_idxs:
          output = gb.op("Unsqueeze", slice_output, axes=unsqueeze_idxs)
          slice_output = [output]
  
      if gather_nd_idx is not None:
          if opset_version < 11:
              raise ValueError(
                  "ONNX-Chainer supports multiple advanced indexing from opset11"
                  ", opset{} is not supported".format(opset_version)
              )
          gather_nd_idx_name = context.add_const(
              gather_nd_idx.T, "indices"
          )
          slice_output.append(gather_nd_idx_name)
          gb.op("GatherND", slice_output)
      elif gather_idx is not None:
          gather_idx_name = context.add_const(gather_idx, "indices")
          slice_output.append(gather_idx_name)
          gb.op("Gather", slice_output, axis=gather_axis)
  
      return gb.nodes(output_names=output_names)
  
imports: import warnings
  import chainer
  import numpy
  import onnx
  from onnx.mapping import NP_TYPE_TO_TENSOR_TYPE
  from onnx_chainer.functions.opset_version import support
  from onnx_chainer import onnx_helper
label_desc: Use image node_id 7 for calling a global function with example usage: convert_GetItem(func, opset_version, input_names, output_names, context) and returns: gb