class_docstr: A collection of data which can be pre-processed in parallel on Spark.
class_docstr_tok: ["A","collection","of","data","which","can","be","pre-processed","in","parallel","on","Spark","."]
docstr: Return a new SparkXShards by applying a function to each shard of this SparkXShards
  
  :param func: python function to process data. The first argument is the data shard.
  :param args: other arguments in this function.
  :return: a new SparkXShards.
docstr_tok: ["Return","a","new","SparkXShards","by","applying","a","function","to","each","shard","of","this","SparkXShards",":","param","func",":","python","function","to","process","data",".","The","first","argument","is","the","data","shard",".",":","param","args",":","other","arguments","in","this","function",".",":","return",":","a","new","SparkXShards","."]
code: def transform_shard(self, func: Callable, *args) -> "SparkXShards":
      """
  
      Return a new SparkXShards by applying a function to each shard of this SparkXShards
  
      :param func: python function to process data. The first argument is the data shard.
      :param args: other arguments in this function.
      :return: a new SparkXShards.
      """
  
      def transform(iter, func, *args):
          for x in iter:
              yield func(x, *args)
  
      transformed_shard = self._create(
          self.rdd.mapPartitions(
              lambda iter: transform(iter, func, *args)
          )
      )
      self._uncache()
      return transformed_shard
  
imports: from py4j.protocol import Py4JError
  from bigdl.orca.data.utils import *
  from bigdl.orca import OrcaContext
  from bigdl.dllib.utils.common import get_node_and_core_number, get_spark_sql_context, get_spark_context
  from bigdl.dllib.utils import nest
  from bigdl.dllib.utils.log4Error import invalidInputError
  import numpy
  from typing import TYPE_CHECKING, Any
  from typing import Callable, Dict, List, Optional, Tuple, Union
label_desc: Use image node_id 5 for calling the SparkXShards obj's underlying member method code with example usage: obj.transform_shard(func) and returns: transformed_shard