code: def melt(
      frame,
      id_vars=None,
      value_vars=None,
      var_name=None,
      value_name="value",
      col_level=None,
  ):
      """Unpivots a DataFrame from wide format to long format,
      optionally leaving identifier variables set.
  
      Parameters
      ----------
      frame : DataFrame
      id_vars : tuple, list, or ndarray, optional
          Column(s) to use as identifier variables.
          default: None
      value_vars : tuple, list, or ndarray, optional
          Column(s) to unpivot.
          default: all columns that are not set as `id_vars`.
      var_name : scalar
          Name to use for the `variable` column.
          default: frame.columns.name or 'variable'
      value_name : str
          Name to use for the `value` column.
          default: 'value'
  
      Returns
      -------
      out : DataFrame
          Melted result
  
      Difference from pandas:
       * Does not support 'col_level' because cuDF does not have multi-index
  
      Examples
      --------
      >>> import cudf
      >>> df = cudf.DataFrame({'A': ['a', 'b', 'c'],
      ...                      'B': [1, 3, 5],
      ...                      'C': [2, 4, 6]})
      >>> df
         A  B  C
      0  a  1  2
      1  b  3  4
      2  c  5  6
      >>> cudf.melt(df, id_vars=['A'], value_vars=['B'])
         A variable  value
      0  a        B      1
      1  b        B      3
      2  c        B      5
      >>> cudf.melt(df, id_vars=['A'], value_vars=['B', 'C'])
         A variable  value
      0  a        B      1
      1  b        B      3
      2  c        B      5
      3  a        C      2
      4  b        C      4
      5  c        C      6
  
      The names of 'variable' and 'value' columns can be customized:
  
      >>> cudf.melt(df, id_vars=['A'], value_vars=['B'],
      ...         var_name='myVarname', value_name='myValname')
         A myVarname  myValname
      0  a         B          1
      1  b         B          3
      2  c         B          5
      """
      if col_level is not None:
          raise NotImplementedError(
              "col_level != None is not supported yet."
          )
  
      # Arg cleaning
  
      # id_vars
      if id_vars is not None:
          if not isinstance(id_vars, abc.Sequence):
              id_vars = [id_vars]
          id_vars = list(id_vars)
          missing = set(id_vars) - set(frame._column_names)
          if not len(missing) == 0:
              raise KeyError(
                  f"The following 'id_vars' are not present"
                  f" in the DataFrame: {list(missing)}"
              )
      else:
          id_vars = []
  
      # value_vars
      if value_vars is not None:
          if not isinstance(value_vars, abc.Sequence):
              value_vars = [value_vars]
          value_vars = list(value_vars)
          missing = set(value_vars) - set(frame._column_names)
          if not len(missing) == 0:
              raise KeyError(
                  f"The following 'value_vars' are not present"
                  f" in the DataFrame: {list(missing)}"
              )
      else:
          # then all remaining columns in frame
          unique_id = set(id_vars)
          value_vars = [
              c for c in frame._column_names if c not in unique_id
          ]
  
      # Error for unimplemented support for datatype
      dtypes = [frame[col].dtype for col in id_vars + value_vars]
      if any(isinstance(typ, cudf.CategoricalDtype) for typ in dtypes):
          raise NotImplementedError(
              "Categorical columns are not yet supported for function"
          )
  
      # Check dtype homogeneity in value_var
      # Because heterogeneous concat is unimplemented
      dtypes = [frame[col].dtype for col in value_vars]
      if len(dtypes) > 0:
          dtype = dtypes[0]
          if any(t != dtype for t in dtypes):
              raise ValueError(
                  "all cols in value_vars must have the same dtype"
              )
  
      # overlap
      overlap = set(id_vars).intersection(set(value_vars))
      if not len(overlap) == 0:
          raise KeyError(
              f"'value_vars' and 'id_vars' cannot have overlap."
              f" The following 'value_vars' are ALSO present"
              f" in 'id_vars': {list(overlap)}"
          )
  
      N = len(frame)
      K = len(value_vars)
  
      def _tile(A, reps):
          series_list = [A] * reps
          if reps > 0:
              return cudf.Series._concat(objs=series_list, index=None)
          else:
              return cudf.Series([], dtype=A.dtype)
  
      # Step 1: tile id_vars
      mdata = {col: _tile(frame[col], K) for col in id_vars}
  
      # Step 2: add variable
      nval = len(value_vars)
      dtype = min_unsigned_type(nval)
      temp = cudf.Series(cupy.repeat(cupy.arange(nval, dtype=dtype), N))
  
      if not var_name:
          var_name = "variable"
  
      mdata[var_name] = cudf.Series(
          cudf.core.column.build_categorical_column(
              categories=value_vars,
              codes=temp._column,
              mask=temp._column.base_mask,
              size=temp._column.size,
              offset=temp._column.offset,
              ordered=False,
          )
      )
  
      # Step 3: add values
      mdata[value_name] = cudf.Series._concat(
          objs=[frame[val] for val in value_vars], index=None
      )
  
      return cudf.DataFrame(mdata)
  
imports: import itertools
  import warnings
  from collections import abc
  from typing import Dict, Optional
  import cupy
  import numpy
  import pandas
  import cudf
  from cudf._lib.transform import one_hot_encode
  from cudf._lib.types import size_type_dtype
  from cudf._typing import Dtype
  from cudf.api.extensions import no_default
  from cudf.core.column import ColumnBase, as_column, column_empty_like
  from cudf.core.column.categorical import CategoricalColumn
  from cudf.utils.dtypes import min_unsigned_type
label_desc: Use image node_id 5 for calling a global function with example usage: melt(frame, id_vars, value_vars, var_name, value_name, col_level) and returns: cudf, cudf, cudf