class_docstr: Shuffles / writes Examples beam collection to sharded TFRecord files.
  
  The given examples are not directly writen to the final tfrecord file, but to
  temporary files.
class_docstr_tok: ["Shuffles","\/","writes","Examples","beam","collection","to","sharded","TFRecord","files",".","The","given","examples","are","not","directly","writen","to","the","final","tfrecord","file",",","but","to","temporary","files","."]
docstr: Assigns a shard id to the example.
docstr_tok: ["Assigns","a","shard","id","to","the","example","."]
code: def _assign_shard(
      self,
      key_serialized_example: Tuple[Any, bytes],
      num_shards: int,
      largest_key: List[int],
  ) -> Tuple[int, Tuple[Any, bytes]]:
      """Assigns a shard id to the example."""
      key, _ = key_serialized_example
      largest_key = largest_key[0]
      shard_number = shuffle.get_bucket_number(
          hkey=key, num_buckets=num_shards, max_hkey=largest_key
      )
      self._get_distribution(name="ShardDistribution").update(
          shard_number
      )
      return (shard_number, key_serialized_example)
  
imports: import dataclasses
  import functools
  import itertools
  import json
  import os
  from typing import Any, Iterable, List, Optional, Tuple
  from absl import logging
  from etils import epath
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import example_serializer
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import hashing
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import shuffle
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.utils import file_utils
  from tensorflow_datasets.core.utils import shard_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import apache_beam
label_desc: Use image node_id 11 for calling the BeamWriter obj's underlying member method code with example usage: obj._assign_shard(key_serialized_example, num_shards, largest_key) and returns: shard_number,  key_serialized_example