code: def get_block_sizes_runtime_device(
      block_sizes: List[int],
      runtime_device: torch.device,
      tensor_cache: Dict[str, Tuple[torch.Tensor, List[torch.Tensor]]],
      embedding_shard_metadata: Optional[List[List[int]]] = None,
      dtype: torch.dtype = torch.int32,
  ) -> Tuple[torch.Tensor, List[torch.Tensor]]:
      cache_key: str = "__block_sizes"
      if cache_key not in tensor_cache:
          tensor_cache[cache_key] = (
              torch.tensor(
                  block_sizes,
                  device=runtime_device,
                  dtype=dtype,
              ),
              []
              if embedding_shard_metadata is None
              else [
                  torch.tensor(
                      row_pos,
                      device=runtime_device,
                      dtype=dtype,
                  )
                  for row_pos in embedding_shard_metadata
              ],
          )
  
      return tensor_cache[cache_key]
  
imports: import math
  from typing import Any, cast, Dict, List, Optional, Tuple, TypeVar, Union
  import torch
  import torch.distributed
  from torchrec.distributed.dist_data import EmbeddingsAllToOneReduce, KJTAllToAll, KJTOneToAll, PooledEmbeddingsReduceScatter, VariableBatchPooledEmbeddingsReduceScatter
  from torchrec.distributed.embedding_lookup import GroupedPooledEmbeddingsLookup, InferGroupedPooledEmbeddingsLookup
  from torchrec.distributed.embedding_sharding import BaseEmbeddingDist, BaseEmbeddingLookup, BaseSparseFeaturesDist, bucketize_kjt_before_all2all, EmbeddingSharding, EmbeddingShardingContext, EmbeddingShardingInfo, group_tables
  from torchrec.distributed.embedding_types import BaseGroupedFeatureProcessor, EmbeddingComputeKernel, GroupedEmbeddingConfig, KJTList, ShardedEmbeddingTable
  from torchrec.distributed.types import Awaitable, CommOp, NullShardingContext, QuantizedCommCodecs, ShardedTensorMetadata, ShardingEnv, ShardMetadata
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
  from torchrec.streamable import Multistreamable
label_desc: Use image node_id 3 for calling a global function with example usage: get_block_sizes_runtime_device(block_sizes, runtime_device, tensor_cache, embedding_shard_metadata, dtype) and returns: tensor_cache