class_docstr: Base class for distributed computation models and defines interface methods.
  This class is public and should be used for other custom derived distributed models.
class_docstr_tok: ["Base","class","for","distributed","computation","models","and","defines","interface","methods",".","This","class","is","public","and","should","be","used","for","other","custom","derived","distributed","models","."]
code: def _encode_input_data(
      x: Union[torch.Tensor, float, str, None], is_src: bool
  ) -> List[int]:
      encoded_msg = [-1] * 512
      if not is_src:
          # Discard input type if not source
          return encoded_msg
  
      if isinstance(x, torch.Tensor):
          shape = x.shape
          dtype = str(x.dtype)
          msg = [
              0,
              len(shape),
              *shape,
              len(dtype),
              *list(bytearray(dtype, "utf-8")),
          ]
          encoded_msg[: len(msg)] = msg
      elif isinstance(x, Number):
          encoded_msg[0] = 1
      elif isinstance(x, str):
          encoded_msg[0] = 2
      return encoded_msg
  
imports: from abc import ABCMeta, abstractmethod
  from numbers import Number
  from typing import Any, Callable, cast, List, Optional, Union
  import torch
  from packaging.version import Version
label_desc: Use image node_id 18 for calling the ComputationModel obj's underlying member method code with example usage: obj._encode_input_data(x, is_src) and returns: encoded_msg, encoded_msg