code: def get_tensor_sharding(tensor):
      """Returns sharding attribute of a Tensor.
  
      Args:
        tensor: a Tensor.
  
      Returns:
        The attribute representing XLA sharding on tensor's op.
      """
      try:
          return get_op_sharding(tensor.op)
      except AttributeError:
          # AttributeError: Tensor.op is meaningless when eager execution is enabled.
          return None
  
imports: import numpy
  from tensorflow.compiler.tf2xla.python import xla
  from local_xla.xla import xla_data_pb2
  from tensorflow.core.framework import attr_value_pb2
label_desc: Use image node_id 8 for calling a global function with example usage: get_tensor_sharding(tensor) and returns: get_op_sharding, None