code: def print_schema_as_code(dtype: T.DataType) -> str:
      """Represent DataType (including StructType) as valid Python code.
  
      :param dtype: The input DataType or Schema object
      :type dtype: pyspark.sql.types.DataType
      :return: A valid python code which generate the same schema.
      :rtype: str
      """
      res = []
      if isinstance(dtype, T.StructType):
          res.append("StructType(\n\tfields=[")
          for field in dtype.fields:
              for line in _repr_column(field).split("\n"):
                  res.append("\n\t\t")
                  res.append(line)
              res.append(",")
          res.append("\n\t]\n)")
  
      elif isinstance(dtype, T.ArrayType):
          res.append("ArrayType(")
          res.append(print_schema_as_code(dtype.elementType))
          res.append(")")
  
      elif isinstance(dtype, T.MapType):
          res.append("MapType(")
          res.append(f"\n\t{print_schema_as_code(dtype.keyType)},")
          for line in print_schema_as_code(dtype.valueType).split("\n"):
              res.append("\n\t")
              res.append(line)
          res.append(",")
          res.append(f"\n\t{dtype.valueContainsNull},")
          res.append("\n)")
  
      elif isinstance(dtype, T.DecimalType):
          res.append(f"DecimalType({dtype.precision}, {dtype.scale})")
  
      elif str(dtype).endswith("()"):
          # PySpark 3.3+
          res.append(str(dtype))
      else:
          res.append(f"{dtype}()")
  
      return "".join(res)
  
file_path: quinn/quinn/schema_helpers.py
imports: from __future__ import annotations
  import json
  from typing import Optional
  from pyspark.sql import SparkSession
  from pyspark.sql import types
label_desc: Use image node_id 1 for calling a global function with example usage: print_schema_as_code(dtype) and returns: str