code: def _to_matrix(cls, ctx, xp, x, op):
      assert x.ndim == 1
      out_chunk_size = op.reduce_sizes
      out_shape = tuple(sum(ns) for ns in out_chunk_size)
      d = out_shape[0]
  
      # calculate the index for the 1-d chunk
      index = xp.arange(x.shape[0])
      index = xp.add(index, op.start_positions[0], out=index)
  
      # input length for each row
      row_sizes = xp.arange(d, -1, -1)
      row_sizes[0] = 0
      xp.cumsum(row_sizes[1:], out=row_sizes[1:])
      # calculate row for each element
      rows = xp.searchsorted(row_sizes, index, side="right")
      xp.subtract(rows, 1, out=rows)
      # calculate col for each element
      # offsets
      cols_offsets = xp.arange(1, d + 1)
      cols = xp.empty(x.shape, dtype=np.int32)
      xp.add(
          xp.subtract(index, row_sizes[rows], out=cols),
          cols_offsets[rows],
          out=cols,
      )
  
      cum_sizes = [
          [0] + np.cumsum(cs).tolist() for cs in out_chunk_size
      ]
      for idx in itertools.product(
          *(range(len(ns)) for ns in out_chunk_size)
      ):
          i, j = idx
          row_range = cum_sizes[0][i], cum_sizes[0][i + 1]
          col_range = cum_sizes[1][j], cum_sizes[1][j + 1]
          # for upper
          filtered = (
              (rows >= row_range[0])
              & (rows < row_range[1])
              & (cols >= col_range[0])
              & (cols < col_range[1])
          )
          inds_tup = (
              rows[filtered] - row_range[0],
              cols[filtered] - col_range[0],
          )
          upper_inds = xp.ravel_multi_index(
              inds_tup, (out_chunk_size[0][i], out_chunk_size[1][j])
          )
          upper_values = x[filtered]
          # for lower
          filtered = (
              (rows >= col_range[0])
              & (rows < col_range[1])
              & (cols >= row_range[0])
              & (cols < row_range[1])
          )
          inds_tup = (
              cols[filtered] - row_range[0],
              rows[filtered] - col_range[0],
          )
          lower_inds = xp.ravel_multi_index(
              inds_tup, (out_chunk_size[0][i], out_chunk_size[1][j])
          )
          lower_values = x[filtered]
  
          inds = xp.concatenate([upper_inds, lower_inds])
          values = xp.concatenate([upper_values, lower_values])
  
          ctx[op.outputs[0].key, idx] = inds, values
  
imports: import itertools
  import numpy
  from ....None import opcodes
  from ....core import recursive_tile
  from ....core.operand import OperandStage
  from ....serialization.serializables import FieldTypes, KeyField, BoolField, TupleField
  from ....config import options
  from ....utils import has_unknown_shape, require_module
  from ...core import TensorOrder
  from ...operands import TensorMapReduceOperand, TensorOperandMixin, TensorShuffleProxy
  from ...datasource import ascontiguousarray, array, zeros
  from ...arithmetic import equal
  from ...utils import decide_chunk_sizes
  from ...array_utils import as_same_device, device, cp
label_desc: Use image node_id 14 for calling the TensorSquareform obj's underlying member method code with example usage: obj._to_matrix(cls, ctx, xp, x, op) without return types