code: def _serialize_sharding(
      builder: flatbuffers.Builder, s: _export.Sharding
  ) -> int:
      proto = None
      if s is None:
          kind = ser_flatbuf.ShardingKind.unspecified
      else:
          kind = ser_flatbuf.ShardingKind.hlo_sharding
          proto_bytes = s.to_proto().SerializeToString()  # type: ignore[union-attr]
          proto = builder.CreateByteVector(proto_bytes)
  
      ser_flatbuf.ShardingStart(builder)
      ser_flatbuf.ShardingAddKind(builder, kind)
      if proto is not None:
          ser_flatbuf.ShardingAddHloShardingProto(builder, proto)
      return ser_flatbuf.ShardingEnd(builder)
  
imports: from typing import Callable, TypeVar
  from collections.abc import Sequence
  from jax._src import core
  from jax._src import dtypes
  from jax._src import effects
  from jax._src import tree_util
  from jax._src.lib import xla_client
  from jax.experimental.export import serialization_generated
  from jax.experimental.export import _export
  from jax.experimental import export
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: _serialize_sharding(builder, s) and returns: ser_flatbuf