code: def squareform(X, force="no", checks=True, chunk_size=None):
      """
      Convert a vector-form distance vector to a square-form distance
      matrix, and vice-versa.
  
      Parameters
      ----------
      X : Tensor
          Either a condensed or redundant distance matrix.
      force : str, optional
          As with MATLAB(TM), if force is equal to ``'tovector'`` or
          ``'tomatrix'``, the input will be treated as a distance matrix or
          distance vector respectively.
      checks : bool, optional
          If set to False, no checks will be made for matrix
          symmetry nor zero diagonals. This is useful if it is known that
          ``X - X.T1`` is small and ``diag(X)`` is close to zero.
          These values are ignored any way so they do not disrupt the
          squareform transformation.
  
      Returns
      -------
      Y : Tensor
          If a condensed distance matrix is passed, a redundant one is
          returned, or if a redundant one is passed, a condensed distance
          matrix is returned.
  
      Notes
      -----
      1. v = squareform(X)
  
         Given a square d-by-d symmetric distance matrix X,
         ``v = squareform(X)`` returns a ``d * (d-1) / 2`` (or
         :math:`{n \\choose 2}`) sized vector v.
  
        :math:`v[{n \\choose 2}-{n-i \\choose 2} + (j-i-1)]` is the distance
        between points i and j. If X is non-square or asymmetric, an error
        is returned.
  
      2. X = squareform(v)
  
        Given a ``d*(d-1)/2`` sized v for some integer ``d >= 2`` encoding
        distances as described, ``X = squareform(v)`` returns a d by d distance
        matrix X.  The ``X[i, j]`` and ``X[j, i]`` values are set to
        :math:`v[{n \\choose 2}-{n-i \\choose 2} + (j-i-1)]` and all
        diagonal elements are zero.
  
      """
  
      X = ascontiguousarray(X)
  
      op = TensorSquareform(checks=checks, dtype=X.dtype, gpu=X.op.gpu)
      return op(X, force=force, chunk_size=chunk_size)
  
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 1 for calling a global function with example usage: squareform(X, force, checks, chunk_size) and returns: op