def METHOD_NAME(type_proto: pb.Type) -> computation_types.Type:
  """Deserializes 'type_proto' as a `tff.Type`.
  Note: Currently only deserialization for tensor, named tuple, sequence, and
  function types is implemented.
  Args:
    type_proto: A `pb.Type` to deserialize.
  Returns:
    The corresponding instance of `tff.Type`.
  Raises:
    TypeError: If the argument is of the wrong type.
    NotImplementedError: For type variants for which deserialization is not
      implemented.
  """
  type_variant = type_proto.WhichOneof('type')
  if type_variant == 'tensor':
    tensor_proto = type_proto.tensor
    return computation_types.TensorType(
        dtype=tf.dtypes.as_dtype(tensor_proto.dtype),
        shape=_to_tensor_shape(tensor_proto),
    )
  elif type_variant == 'sequence':
    return computation_types.SequenceType(
        METHOD_NAME(type_proto.sequence.element)
    )
  elif type_variant == 'struct':
    def empty_str_to_none(s):
      if not s:
        return None
      return s
    return computation_types.StructType(
        [
            (empty_str_to_none(e.name), METHOD_NAME(e.value))
            for e in type_proto.struct.element
        ],
        convert=False,
    )
  elif type_variant == 'function':
    if type_proto.function.HasField('parameter'):
      parameter_type = METHOD_NAME(type_proto.function.parameter)
    else:
      parameter_type = None
    result_type = METHOD_NAME(type_proto.function.result)
    return computation_types.FunctionType(
        parameter=parameter_type, result=result_type
    )
  elif type_variant == 'placement':
    return computation_types.PlacementType()
  elif type_variant == 'federated':
    placement_oneof = type_proto.federated.placement.WhichOneof('placement')
    if placement_oneof == 'value':
      return computation_types.FederatedType(
          member=METHOD_NAME(type_proto.federated.member),
          placement=placements.uri_to_placement_literal(
              type_proto.federated.placement.value.uri
          ),
          all_equal=type_proto.federated.all_equal,
      )
    else:
      raise NotImplementedError(
          'Deserialization of federated types with placement spec as {} '
          'is not currently implemented yet.'.format(placement_oneof)
      )
  else:
    raise NotImplementedError('Unknown type variant {}.'.format(type_variant))