def _get_arg(args_dict: Dict[Text, Any], tensor_name: Text,
             context: _Context) -> Any:
  """Gets the value of the specified function argument."""
  if "." not in tensor_name:
    if tensor_name not in args_dict:
      raise ValueError(
          "Require: Arg not found in function `{}`: {} (Have args: {})"
          .format(context.func_name, tensor_name, " ".join(args_dict)))
    return args_dict[tensor_name]

  # Allow tensor names to be attributes of args (e.g. items in named tuples).
  # The simple case of no dots in the name is handled above.
  # TODO(jhclark): Document this functionality. (including "RESULT.starts")
  name_chain = tensor_name.split(".")
  result = args_dict.get(name_chain[0], None)
  if result is None:
    raise ValueError("Require: Arg `{}` not found in function `{}`: {} "
                     "(Have args: {})".format(name_chain[0], context.func_name,
                                              tensor_name, " ".join(args_dict)))
  for name_part in name_chain[1:]:
    try:
      result = getattr(result, name_part)
    except AttributeError as e:
      raise AttributeError(
          "Require: Attribute `{}` not found on object `{}` in function `{}` "
          "(resolving `{}`): {}".format(name_part, type(result),
                                        context.func_name, tensor_name, str(e)))
  return result
Gets the value of the specified function argument.
language/canine/tensor_contracts.py