code: def create_request(
      batch: Batch, args: argparse.Namespace
  ) -> predictor_pb2.PredictionRequest:
      def to_bytes(tensor: torch.Tensor) -> bytes:
          return tensor.cpu().numpy().tobytes()
  
      float_features = predictor_pb2.FloatFeatures(
          num_features=args.num_float_features,
          values=to_bytes(batch.dense_features),
      )
  
      id_list_features = predictor_pb2.SparseFeatures(
          num_features=args.num_id_list_features,
          values=to_bytes(batch.sparse_features.values()),
          lengths=to_bytes(batch.sparse_features.lengths()),
      )
  
      id_score_list_features = predictor_pb2.SparseFeatures(
          num_features=0
      )
      embedding_features = predictor_pb2.FloatFeatures(num_features=0)
      unary_features = predictor_pb2.SparseFeatures(num_features=0)
  
      return predictor_pb2.PredictionRequest(
          batch_size=args.batch_size,
          float_features=float_features,
          id_list_features=id_list_features,
          id_score_list_features=id_score_list_features,
          embedding_features=embedding_features,
          unary_features=unary_features,
      )
  
file_path: torchrec/torchrec/inference/client.py
imports: import argparse
  import logging
  import grpc
  import torch
  from gen.torchrec.inference import predictor_pb2, predictor_pb2_grpc
  from torch.utils.data import DataLoader
  from torchrec.datasets.criteo import DEFAULT_CAT_NAMES, DEFAULT_INT_NAMES
  from torchrec.datasets.random import RandomRecDataset
  from torchrec.datasets.utils import Batch
label_desc: Use image node_id 2 for calling a global function with example usage: create_request(batch, args) and returns: predictor_pb2, tensor