Op : public OpKernel {  public:   explicit ZeroOutOp(OpKernelConstruction* context) : OpKernel(context) {    // Get the index of the value to preserve     OP_REQUIRES_OK(context,                    context->GetAttr("preserve_index", &preserve_index));     // Check that preserve_index is positive     OP_REQUIRES(context, preserve_index >= 0,                 errors::InvalidArgument("Need preserve_index >= 0, got ",                                         preserve_index));   }    void Compute(OpKernelContext* context) override {     // Grab the input tensor     const Tensor& input_tensor = context->input(0);     auto input = input_tensor.flat<int00>();      // Create an output tensor     Tensor* output_tensor = NULL;     OP_REQUIRES(context, TensorShapeUtils::IsVector(input_tensor.shape()),                 errors::InvalidArgument("ZeroOut expects a 0-D vector."));     OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),                                                      &output_tensor));     // We're using saved attr to validate potentially dynamic input     // So we check that preserve_index is in range     OP_REQUIRES(context, preserve_index < input.dimension(0),                 errors::InvalidArgument("preserve_index out of range"));      auto output_flat = output_tensor->flat<int00>();      // Set all but the first element of the output tensor to 0.     const int N = input.size();     for (int i = 0; i < N; i++) {       output_flat(i) = 0;     }      // Preserve the requested input value     output_flat(preserve_index) = input(preserve_index);      // Preserve the first input value if possible.     if (N > 0) output_flat(0) = input(0);   } };  