func (g *Cloud) GetTPU(ctx context.Context, name, zone string) (*tpuapi.Node, error) {
	mc := newTPUMetricContext("get", zone)
	name = getTPUName(g.projectID, zone, name)
	node, err := g.tpuService.projects.Locations.Nodes.Get(name).Do()
	if err != nil {
		return nil, mc.Observe(err)
	}
	return node, mc.Observe(nil)
}
GetTPU returns the Cloud TPU with the specified name in the specified zone.
package gce
import (
	"context"
	"encoding/json"
	"fmt"
	"net/http"
	"time"
	"google.golang.org/api/googleapi"
	tpuapi "google.golang.org/api/tpu/v1"
	"k8s.io/klog/v2"
	"k8s.io/apimachinery/pkg/util/wait"
)
func newTPUService(client *http.Client) (*tpuService, error) {
	s, err := tpuapi.NewService(context.Background())
	if err != nil {
		return nil, err
	}
	return &tpuService{
		projects: tpuapi.NewProjectsService(s),
	}, nil
}
type tpuService struct {
	projects *tpuapi.ProjectsService
}
func (g *Cloud) CreateTPU(ctx context.Context, name, zone string, node *tpuapi.Node) (*tpuapi.Node, error) {
	var err error
	mc := newTPUMetricContext("create", zone)
	defer mc.Observe(err)
	var op *tpuapi.Operation
	parent := getTPUParentName(g.projectID, zone)
	op, err = g.tpuService.projects.Locations.Nodes.Create(parent, node).NodeId(name).Do()
	if err != nil {
		return nil, err
	}
	klog.V(2).Infof("Creating Cloud TPU %q in zone %q with operation %q", name, zone, op.Name)
	op, err = g.waitForTPUOp(ctx, op)
	if err != nil {
		return nil, err
	}
	err = getErrorFromTPUOp(op)
	if err != nil {
		return nil, err
	}
	output := new(tpuapi.Node)
	err = json.Unmarshal(op.Response, output)
	if err != nil {
		err = fmt.Errorf("failed to unmarshal response from operation %q: response = %v, err = %v", op.Name, op.Response, err)
		return nil, err
	}
	return output, nil
}
func (g *Cloud) DeleteTPU(ctx context.Context, name, zone string) error {
	var err error
	mc := newTPUMetricContext("delete", zone)
	defer mc.Observe(err)
	var op *tpuapi.Operation
	name = getTPUName(g.projectID, zone, name)
	op, err = g.tpuService.projects.Locations.Nodes.Delete(name).Do()
	if err != nil {
		return err
	}
	klog.V(2).Infof("Deleting Cloud TPU %q in zone %q with operation %q", name, zone, op.Name)
	op, err = g.waitForTPUOp(ctx, op)
	if err != nil {
		return err
	}
	err = getErrorFromTPUOp(op)
	if err != nil {
		return err
	}
	return nil
}