Add checks to ensure that the device indices in the sharding are valid.
Add checks to ensure that the device indices in the sharding are valid.

The size of input_mapping depends on metadata.num_cores_per_replica(). And metadata is a protobuffer assigned by the poc.mlir. Missing validation for the index of input_mappings will lead to an out-of-bound vulnerability.
